Gatling proxy configuration - scala

This is a followup to this question. I'm using the same configuration. However, I'm trying to use an internal website through a proxy server. I'm not sure if the following the correct way to configure a proxy in the simulation.
val httpConf = http.proxy("http://proxy.server.address", 8080)
Here is my modified code.
package foo
import io.gatling.core.Predef._
import io.gatling.core.session.Expression
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import io.gatling.http.Headers.Names._
import io.gatling.http.Headers.Values._
import scala.concurrent.duration._
import bootstrap._
import assertions._
class SimpleSimulation extends Simulation {
val httpConf = http.proxy("http://proxy.server.address", 8080)
val scn = scenario("My scenario")
.exec(http("My Page")
.get("http://10.128.3.232:9201/index.html"))
setUp(scn.inject(atOnce(50 user))).protocols(httpConf)
}
I've also modified conf/gatling.conf to include the proxy. I'm not sure what's the correct way to configure the proxy.
http {
#baseUrls = "" # default value for the base HTTP URLs
proxy {
host = "http://proxy.server.address" # proxy host (blank means no proxy)
port = 8080 # HTTP port
securedPort = -1 # HTTPS port (-1 means no HTTPS proxy)
#username = "" # proxy username (blank means no credentials)
#password = "" # proxy password
}
I'm getting the following exception when I run the simulation.
17:09:15.654 [INFO ] i.g.h.a.HttpRequestAction - Sending request 'My Page': scenario 'My scenario', userId #49
17:09:15.655 [WARN ] i.g.h.a.AsyncHandler - Request 'My Page' failed
java.nio.channels.UnresolvedAddressException: null
at sun.nio.ch.Net.checkAddress(Net.java:36) ~[na:1.6.0_51]
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:512) ~[na:1.6.0_51]
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.connect(NioClientSocketPipelineSink.java:108) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:70) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:54) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.handler.codec.http.HttpClientCodec.handleDownstream(HttpClientCodec.java:97) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.handler.stream.ChunkedWriteHandler.handleDownstream(ChunkedWriteHandler.java:109) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.channel.Channels.connect(Channels.java:634) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.channel.AbstractChannel.connect(AbstractChannel.java:207) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:229) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:182) ~[netty-3.6.6.Final.jar:na]
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1026) [async-http-client-1.7.19.20130706.jar:na]
Wrapped by: java.net.ConnectException: http://10.128.3.232:9201/index.html
at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:103) ~[async-http-client-1.7.19.20130706.jar:na]
at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:427) [netty-3.6.6.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelFuture.addListener(DefaultChannelFuture.java:145) [netty-3.6.6.Final.jar:na]
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1068) [async-http-client-1.7.19.20130706.jar:na]
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:890) [async-http-client-1.7.19.20130706.jar:na]
at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:520) [async-http-client-1.7.19.20130706.jar:na]
at io.gatling.http.ahc.HttpClient$.sendHttpRequest(HttpClient.scala:144) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction.io$gatling$http$action$HttpRequestAction$$sendRequest$1(HttpRequestAction.scala:75) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1$$anonfun$apply$2.apply(HttpRequestAction.scala:84) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1$$anonfun$apply$2.apply(HttpRequestAction.scala:81) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.core.validation.Success.map(Validation.scala:27) [gatling-core-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1.apply(HttpRequestAction.scala:81) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1.apply(HttpRequestAction.scala:80) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.core.validation.Success.flatMap(Validation.scala:28) [gatling-core-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction.executeOrFail(HttpRequestAction.scala:80) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.core.action.Failable$class.execute(Actions.scala:82) [gatling-core-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction.execute(HttpRequestAction.scala:54) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.core.action.Action$$anonfun$receive$1.applyOrElse(Actions.scala:42) [gatling-core-2.0.0-M3a.jar:na]
at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:166) [scala-library-2.10.2.jar:na]
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425) [akka-actor_2.10-2.1.4.jar:na]
at akka.actor.ActorCell.invoke(ActorCell.scala:386) [akka-actor_2.10-2.1.4.jar:na]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230) [akka-actor_2.10-2.1.4.jar:na]
at akka.dispatch.Mailbox.run(Mailbox.scala:212) [akka-actor_2.10-2.1.4.jar:na]
at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:506) [akka-actor_2.10-2.1.4.jar:na]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.10.2.jar:na]
17:09:15.656 [WARN ] i.g.h.a.AsyncHandlerActor - Request 'My Page' failed : http://10.128.3.232:9201/emontage/home.html
17:09:15.656 [DEBUG] i.g.h.a.AsyncHandlerActor -
>>>>>>>>>>>>>>>>>>>>>>>>>>
Request:
My Page: KO http://10.128.3.232:9201/index.html
=========================
Session:
Session(My scenario,49,Map(),1378847355391,0,List(),List(KO),List(),List())
=========================
HTTP request:
GET http://10.128.3.232:9201/index.html
=========================
HTTP response:
<<<<<<<<<<<<<<<<<<<<<<<<<

This has changed since 2013 when the question was originally answered. Their documentation link has changed, and the function definition for proxy has changed to be:
val httpConf = http.proxy(Proxy("myProxyHost", 8080))

As stated in the documentation, the first parameter is the host name, not the url.
Please use:
val httpConf = http.proxy("proxy.server.address", 8080)

Related

Wiremock using certificate not working on Windows

This error only happens on the Windows OS. On Linux and MacOS it works fine.
I've made sure that the password for the certificates is correct, that they do exist in the mentioned location and that the port is available.
Language is Kotlin. Testing framework is Kotest.
Certificates are under:
test/resources/ssl-certs/client-cert.p12
test/resources/ssl-certs/server-cert.p12
import com.github.tomakehurst.wiremock.client.WireMock.aResponse
import com.github.tomakehurst.wiremock.client.WireMock.get
import com.github.tomakehurst.wiremock.http.RequestMethod
import com.github.tomakehurst.wiremock.matching.ContainsPattern
import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder.newRequestPattern
import com.github.tomakehurst.wiremock.matching.UrlPattern
import my.test.library.apigee.bankingapi.BankingApiApigeePropertiesFixtures.bankingApiApigeeProperties
import my.test.library.apigee.bankingapi.testutils.mockServer
import io.kotest.assertions.withClue
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import org.springframework.http.HttpMethod
import org.springframework.http.HttpStatus
import java.net.URI
class ApigeeSslConnectionFactoryBuilderTest : StringSpec({
val sslServerPort = 10443
val apigeeMockServer = mockServer {
httpDisabled(true)
httpsPort(sslServerPort)
keystorePath(ApigeeSslConnectionFactoryBuilderTest::class.java.getResource("/ssl-certs/server-cert.p12").path)
keystoreType("pkcs12")
keystorePassword("wiremock-truststore-password")
keyManagerPassword("wiremock-truststore-password")
needClientAuth(true)
trustStorePath(ApigeeSslConnectionFactoryBuilderTest::class.java.getResource("/ssl-certs/client-cert.p12").path)
trustStorePassword("ssl-password")
trustStoreType("pkcs12")
}
beforeSpec {
apigeeMockServer.stubFor(
get("/some-url").willReturn(
aResponse().withStatus(200)
)
)
}
val sut = ApigeeSslConnectionFactoryBuilder(
bankingApiApigeeProperties(
url = "https://localhost:$sslServerPort",
sslCertificateURL = "/ssl-certs/client-cert.p12",
sslCertificatePassword = "ssl-password"
)
)
"#buildSSlRequestFactory" {
withClue("ssl configuration is used") {
val request = sut.buildSSlRequestFactory().createRequest(URI.create("https://localhost:$sslServerPort/some-url"), HttpMethod.GET)
val response = request.execute()
response.statusCode shouldBe HttpStatus.OK
apigeeMockServer.verify(
newRequestPattern(RequestMethod.GET, UrlPattern(ContainsPattern("/some-url"), false))
)
}
}
})
The error I'm getting (only on Windows):
14:09:46.196 [qtp1976741669-37] DEBUG org.eclipse.jetty.io.WriteFlusher - ignored: WriteFlusher#1502467f{IDLE}->null
javax.net.ssl.SSLHandshakeException: Read error: ssl=0000029A3CD9AFE8: Failure in SSL library, usually a protocol error
error:100000c0:SSL routines:OPENSSL_internal:PEER_DID_NOT_RETURN_A_CERTIFICATE (..\ssl\tls13_both.cc:324 00007FFD46C71BC0:0x00000000)
.
.
.
.
Process finished with exit code -1
Software caused connection abort: recv failed
javax.net.ssl.SSLProtocolException: Software caused connection abort: recv failed
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:126)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)
at java.base/sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1314)
at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:839)
at org.apache.http.impl.conn.LoggingInputStream.read(LoggingInputStream.java:84)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:87)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.http.client.BufferingClientHttpRequestWrapper.executeInternal(BufferingClientHttpRequestWrapper.java:63)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at my.test.library.apigee.bankingapi.certificates.ApigeeSslConnectionFactoryBuilderTest$1$2.invokeSuspend(ApigeeSslConnectionFactoryBuilderTest.kt:57)
at my.test.library.apigee.bankingapi.certificates.ApigeeSslConnectionFactoryBuilderTest$1$2.invoke(ApigeeSslConnectionFactoryBuilderTest.kt)
at io.kotest.core.runtime.ExecutionsKt$executeWithBehaviours$2$1.invokeSuspend(executions.kt:16)
at io.kotest.core.runtime.ExecutionsKt$executeWithBehaviours$2$1.invoke(executions.kt)
at io.kotest.core.runtime.ExecutionsKt.wrapTestWithGlobalAssert(executions.kt:43)
at io.kotest.core.runtime.ExecutionsKt$executeWithBehaviours$2.invokeSuspend(executions.kt:15)
at io.kotest.core.runtime.ExecutionsKt$executeWithBehaviours$2.invoke(executions.kt)
at io.kotest.core.runtime.ExecutionsKt$wrapTestWithAssertionModeCheck$2.invokeSuspend(executions.kt:29)
at io.kotest.core.runtime.ExecutionsKt$wrapTestWithAssertionModeCheck$2.invoke(executions.kt)
at io.kotest.core.test.AssertionModeKt.executeWithAssertionsCheck(AssertionMode.kt:39)
at io.kotest.core.runtime.ExecutionsKt.wrapTestWithAssertionModeCheck(executions.kt:28)
at io.kotest.core.runtime.ExecutionsKt.executeWithBehaviours(executions.kt:14)
at io.kotest.core.runtime.TestCaseExecutor$executeAndWait$2$1$1$3$1.invokeSuspend(TestCaseExecutor.kt:195)
at io.kotest.core.runtime.TestCaseExecutor$executeAndWait$2$1$1$3$1.invoke(TestCaseExecutor.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:91)
at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:194)
at io.kotest.core.runtime.TestCaseExecutor$executeAndWait$2$1$1$3.invokeSuspend(TestCaseExecutor.kt:189)
at io.kotest.core.runtime.TestCaseExecutor$executeAndWait$2$1$1$3.invoke(TestCaseExecutor.kt)
at io.kotest.core.runtime.ReplayKt.replay(replay.kt:19)
at io.kotest.core.runtime.TestCaseExecutor$executeAndWait$2$1$1.invokeSuspend(TestCaseExecutor.kt:184)
at io.kotest.core.runtime.TestCaseExecutor$executeAndWait$2$1$1.invoke(TestCaseExecutor.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturnIgnoreTimeout(Undispatched.kt:102)
at kotlinx.coroutines.TimeoutKt.setupTimeout(Timeout.kt:120)
at kotlinx.coroutines.TimeoutKt.withTimeout(Timeout.kt:37)
at io.kotest.core.runtime.TestCaseExecutor$executeAndWait$2$1.invokeSuspend(TestCaseExecutor.kt:183)
at io.kotest.core.runtime.TestCaseExecutor$executeAndWait$2$1.invoke(TestCaseExecutor.kt)
at io.kotest.core.runtime.ExecutorExecutionContext$executeWithTimeoutInterruption$$inlined$suspendCoroutine$lambda$2.invokeSuspend(ExecutorExecutionContext.kt:47)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at io.kotest.core.runtime.ExecutorExecutionContext.executeWithTimeoutInterruption-D5N0EJY(ExecutorExecutionContext.kt:46)
at io.kotest.core.runtime.TestCaseExecutor$executeAndWait$2.invokeSuspend(TestCaseExecutor.kt:182)
at io.kotest.core.runtime.TestCaseExecutor$executeAndWait$2.invoke(TestCaseExecutor.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturnIgnoreTimeout(Undispatched.kt:102)
at kotlinx.coroutines.TimeoutKt.setupTimeout(Timeout.kt:120)
at kotlinx.coroutines.TimeoutKt.withTimeout(Timeout.kt:37)
at io.kotest.core.runtime.TestCaseExecutor.executeAndWait(TestCaseExecutor.kt:180)
at io.kotest.core.runtime.TestCaseExecutor.invokeTestCase(TestCaseExecutor.kt:149)
at io.kotest.core.runtime.TestCaseExecutor.executeActiveTest(TestCaseExecutor.kt:118)
at io.kotest.core.runtime.TestCaseExecutor$intercept$2.invokeSuspend(TestCaseExecutor.kt:69)
at io.kotest.core.runtime.TestCaseExecutor$intercept$2.invoke(TestCaseExecutor.kt)
at io.kotest.core.runtime.TestCaseExecutor.executeIfActive(TestCaseExecutor.kt:83)
at io.kotest.core.runtime.TestCaseExecutor.intercept(TestCaseExecutor.kt:69)
at io.kotest.core.runtime.TestCaseExecutor.execute(TestCaseExecutor.kt:50)
at io.kotest.core.engine.SingleInstanceSpecRunner.runTest(SingleInstanceSpecRunner.kt:61)
at io.kotest.core.engine.SingleInstanceSpecRunner$execute$2$invokeSuspend$$inlined$invoke$lambda$1.invokeSuspend(SingleInstanceSpecRunner.kt:71)
at io.kotest.core.engine.SingleInstanceSpecRunner$execute$2$invokeSuspend$$inlined$invoke$lambda$1.invoke(SingleInstanceSpecRunner.kt)
at io.kotest.core.engine.SpecRunner$runParallel$$inlined$map$lambda$2$1.invokeSuspend(SpecRunner.kt:78)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at io.kotest.core.engine.SpecRunner$runParallel$$inlined$map$lambda$2.run(SpecRunner.kt:77)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.net.SocketException: Software caused connection abort: recv failed
at java.base/java.net.SocketInputStream.socketRead0(Native Method)
at java.base/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:448)
at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:68)
at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1104)
at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:823)
... 91 more

how to read messages in kafka using Spark Scala API

I am unable to receive messages in msgItr where as in command promt using kafka commands i am able to see the messages in partition. please let me know what is going on here. what should i do get the messages.
I tried to print but nothing prints. May be because it is an RDD and it is printing something on the executor node.
val ssc = new StreamingContext(conf, Seconds(props.getProperty("spark.streaming.batchDuration").toInt))
val topics = Set(props.getProperty("kafkaConf.topic"))
// TODO: Externalize StorageLevel to props file
val storageLevel: StorageLevel = StorageLevel.MEMORY_AND_DISK_SER_2
//"zookeeper.connect" -> "fepp-cdhmn-d2.fepoc.com"
val kafkaParams = Map[String, Object](
// the usual params, make sure to change the port in bootstrap.servers if 9092 is not TLS
"zookeeper.connect" -> props.getProperty("kafkaConf.zookeeper.connect"),
"bootstrap.servers" -> props.getProperty("kafkaConf.bootstrap.servers"),
"group.id" -> props.getProperty("kafkaConf.group.id"),
"zookeeper.connection.timeout.ms" -> props.getProperty("kafkaConf.zookeeper.connection.timeout.ms"),
"security.protocol" -> props.getProperty("kafkaConf.security.protocol"),
"ssl.protocol" -> props.getProperty("kafkaConf.ssl.protocol"),
"ssl.keymanager.algorithm" -> props.getProperty("kafkaConf.ssl.keymanager.algorithm"),
"ssl.enabled.protocols" -> props.getProperty("kafkaConf.ssl.enabled.protocols"),
"ssl.truststore.type" -> props.getProperty("kafkaConf.ssl.truststore.type"),
"ssl.keystore.type" -> props.getProperty("kafkaConf.ssl.keystore.type"),
"ssl.truststore.location" -> props.getProperty("kafkaConf.ssl.truststore.location"),
"ssl.truststore.password" -> props.getProperty("kafkaConf.ssl.truststore.password"),
"ssl.keystore.location" -> props.getProperty("kafkaConf.ssl.keystore.location"),
"ssl.keystore.password" -> props.getProperty("kafkaConf.ssl.keystore.password"),
"ssl.key.password" -> props.getProperty("kafkaConf.ssl.key.password"),
"key.deserializer" -> classOf[StringDeserializer],
"value.deserializer" -> classOf[StringDeserializer],
"auto.offset.reset" -> props.getProperty("kafkaConf.auto.offset.reset"),
"enable.auto.commit" -> (props.getProperty("kafkaConf.enable.auto.commit").toBoolean: java.lang.Boolean),
"key.serializer" -> "org.apache.kafka.common.serialization.StringSerializer",
"value.serializer" -> "org.apache.kafka.common.serialization.StringSerializer"
//"heartbeat.interval.ms" -> props.getProperty("kafkaConf.heartbeat.interval.ms"),
//"session.timeout.ms" -> props.getProperty("kafkaConf.session.timeout.ms")
)
// Must use the direct api as the old api does not support SSL
log.debug("Creating direct kafka stream")
val kafkaStream = KafkaUtils.createDirectStream[String, String](ssc, PreferConsistent,
Subscribe[String, String](topics, kafkaParams))
val res = kafkaStream.foreachRDD((kafkaRdd: RDD[ConsumerRecord[String, String]]) => {
val numPartitions = kafkaRdd.getNumPartitions
log.info(s"Processing RDD with '$numPartitions' partitions.")
// Only one partition for the kafka topic is supported at this time
if (numPartitions != 1) {
throw new RuntimeException("Kafka topic must have 1 partition")
}
val offsetRanges = kafkaRdd.asInstanceOf[HasOffsetRanges].offsetRanges
kafkaRdd.foreachPartition((msgItr: Iterator[ConsumerRecord[String, String]]) => {
val log = LogManager.getRootLogger()
msgItr.foreach((kafkaMsg: ConsumerRecord[String, String]) => {
// Hbase connection Fails here. because of authentication with below error
2018-09-19 15:28:01 INFO ZooKeeper:100 - Client environment:user.home=/home/service_account
2018-09-19 15:28:01 INFO ZooKeeper:100 - Client environment:user.dir=/data/09/yarn/nm/usercache/service_account/appcache/application_1536891989660_9297/container_e208_1536891989660_9297_01_000002
2018-09-19 15:28:01 INFO ZooKeeper:438 - Initiating client connection, connectString=depp-cdhmn-d1.domnnremvd.com:2181,depp-cdhmn-d2.domnnremvd.com:2181,depp-cdhmn-d3.domnnremvd.com:2181 sessionTimeout=90000 watcher=hconnection-0x16648f570x0, quorum=depp-cdhmn-d1.domnnremvd.com:2181,depp-cdhmn-d2.domnnremvd.com:2181,depp-cdhmn-d3.domnnremvd.com:2181, baseZNode=/hbase
2018-09-19 15:28:01 INFO ClientCnxn:975 - Opening socket connection to server depp-cdhmn-d3.domnnremvd.com/999.99.999.777:2181. Will not attempt to authenticate using SASL (unknown error)
2018-09-19 15:28:01 INFO ClientCnxn:852 - Socket connection established, initiating session, client: /999.99.999.999:33314, server: depp-cdhmn-d3.domnnremvd.com/999.99.999.777:2181
2018-09-19 15:28:01 INFO ClientCnxn:1235 - Session establishment complete on server depp-cdhmn-d3.domnnremvd.com/999.99.999.777:2181, sessionid = 0x365cb965ff33958, negotiated timeout = 60000
false
false
2018-09-19 15:28:02 WARN UserGroupInformation:1923 - PriviledgedActionException as:service_account (auth:SIMPLE) cause:javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)]
2018-09-19 15:28:02 WARN RpcClientImpl:675 - Exception encountered while connecting to the server : javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)]
2018-09-19 15:28:02 ERROR RpcClientImpl:685 - SASL authentication failed. The most likely cause is missing or invalid credentials. Consider 'kinit'.
javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)]
at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(GssKrb5Client.java:211)
at org.apache.hadoop.hbase.security.HBaseSaslRpcClient.saslConnect(HBaseSaslRpcClient.java:181)
at org.apache.hadoop.hbase.ipc.RpcClientImpl$Connection.setupSaslConnection(RpcClientImpl.java:618)
at org.apache.hadoop.hbase.ipc.RpcClientImpl$Connection.access$700(RpcClientImpl.java:163)
at org.apache.hadoop.hbase.ipc.RpcClientImpl$Connection$2.run(RpcClientImpl.java:744)
at org.apache.hadoop.hbase.ipc.RpcClientImpl$Connection$2.run(RpcClientImpl.java:741)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1920)
at org.apache.hadoop.hbase.ipc.RpcClientImpl$Connection.setupIOstreams(RpcClientImpl.java:741)
at org.apache.hadoop.hbase.ipc.RpcClientImpl$Connection.writeRequest(RpcClientImpl.java:907)
at org.apache.hadoop.hbase.ipc.RpcClientImpl$Connection.tracedWriteRequest(RpcClientImpl.java:874)
at org.apache.hadoop.hbase.ipc.RpcClientImpl.call(RpcClientImpl.java:1243)
at org.apache.hadoop.hbase.ipc.AbstractRpcClient.callBlockingMethod(AbstractRpcClient.java:227)
at org.apache.hadoop.hbase.ipc.AbstractRpcClient$BlockingRpcChannelImplementation.callBlockingMethod(AbstractRpcClient.java:336)
at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$BlockingStub.isMasterRunning(MasterProtos.java:58383)
at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$MasterServiceStubMaker.isMasterRunning(ConnectionManager.java:1712)
at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStubNoRetries(ConnectionManager.java:1650)
at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStub(ConnectionManager.java:1672)
at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$MasterServiceStubMaker.makeStub(ConnectionManager.java:1701)
at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.getKeepAliveMasterService(ConnectionManager.java:1858)
at org.apache.hadoop.hbase.client.MasterCallable.prepare(MasterCallable.java:38)
at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:134)
at org.apache.hadoop.hbase.client.HBaseAdmin.executeCallable(HBaseAdmin.java:4313)
at org.apache.hadoop.hbase.client.HBaseAdmin.executeCallable(HBaseAdmin.java:4305)
at org.apache.hadoop.hbase.client.HBaseAdmin.listTableNames(HBaseAdmin.java:533)
at org.apache.hadoop.hbase.client.HBaseAdmin.listTableNames(HBaseAdmin.java:517)
at com.company.etl.HbaseConnect.mainMethod(HbaseConnect.scala:39)
at com.company.etl.App$$anonfun$1$$anonfun$apply$2$$anonfun$apply$3.apply(App.scala:205)
at com.company.etl.App$$anonfun$1$$anonfun$apply$2$$anonfun$apply$3.apply(App.scala:178)
at scala.collection.Iterator$class.foreach(Iterator.scala:893)
at org.apache.spark.streaming.kafka010.KafkaRDD$KafkaRDDIterator.foreach(KafkaRDD.scala:189)
at com.company.etl.App$$anonfun$1$$anonfun$apply$2.apply(App.scala:178)
at com.company.etl.App$$anonfun$1$$anonfun$apply$2.apply(App.scala:161)
at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$29.apply(RDD.scala:926)
at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$29.apply(RDD.scala:926)
at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2062)
at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2062)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
at org.apache.spark.scheduler.Task.run(Task.scala:108)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:335)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)
at sun.security.jgss.krb5.Krb5InitCredential.getInstance(Krb5InitCredential.java:147)
at sun.security.jgss.krb5.Krb5MechFactory.getCredentialElement(Krb5MechFactory.java:122)
at sun.security.jgss.krb5.Krb5MechFactory.getMechanismContext(Krb5MechFactory.java:187)
at sun.security.jgss.GSSManagerImpl.getMechanismContext(GSSManagerImpl.java:224)
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:212)
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:179)
at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(GssKrb5Client.java:192)
... 43 more
It's because of kerberos authentications.
Set System Properties.
System.setProperty("java.security.auth.login.config","/your/conf/directory/kafkajaas.conf");
System.setProperty("sun.security.jgss.debug","true");
System.setProperty("javax.security.auth.useSubjectCredsOnly","false");
System.setProperty("java.security.krb5.conf", "/your/krb5/conf/directory/krb5.conf");
You can read data from Cloudera Kafka. (Producer)
val df = spark
.readStream
.format("kafka")
.option("kafka.bootstrap.servers", "xx.xx.xx.xx:9092")
.option("subscribe", "test")
.option("kafka.security.protocol","SASL_PLAINTEXT")
.option("kafka.sasl.kerberos.service.name","kafka")
You can write data to Cloudera Kafka topic (Consumer)
val query = blacklistControl.select(to_json(struct("Column1","Column2")).alias("value"))
.writeStream
.format("kafka")
.option("checkpointLocation", "/your/empty/directory")
.option("kafka.bootstrap.servers", "xx.xx.xx.xx:9092")
.option("kafka.security.protocol","SASL_PLAINTEXT")
.option("kafka.sasl.kerberos.service.name","kafka")
.option("topic", "topic_xdr")
.start()
i faced exactly the same issue. What is happening is the executor node is trying to write to hbase and doesnt have the credentials . What you need to do is pass the keytab file to the executors and explicitly call the KDC authentication WITH In THe executor block
UserGroupInformation.loginUserFromKeytab("hdfs-user#MYCORP.NET",
"/home/hdfs-user/hdfs-user.keytab");
From the stacktrace, it looks like the kafka is authenticated with sasl.
The supported SASL mechanims are:
GSSAPI (Kerberos)
OAUTHBEARER
SCRAM
PLAIN
From your stacktrace, kafka is configured using GSSAPI and you need to
authenticate accordingly. You are authenticating for SSL and not
SASL. Check the this link for steps to authenticate.

Sending mails form grails does not work

I have a problem with sending mails from grails. Add an exception to port 587, but nothing helped. Still an error occur:
Connection refused: connect. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:211)
at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)
at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.mail.MailSendException: Mail server connection failed; nested exception is com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1;
nested exception is:
java.net.ConnectException: Connection refused: connect. Failed messages: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1;
nested exception is:
java.net.ConnectException: Connection refused: connect
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:432)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:345)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)
at grails.plugins.mail.MailMessageBuilder.sendMessage(MailMessageBuilder.groovy:131)
at grails.plugins.mail.MailService.sendMail(MailService.groovy:55)
at grails.plugins.mail.MailService.sendMail(MailService.groovy:59)
at grailsproject.UserController.save(UserController.groovy:31)
... 14 common frames omitted
Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2118)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:712)
at javax.mail.Service.connect(Service.java:366)
at org.springframework.mail.javamail.JavaMailSenderImpl.connectTransport(JavaMailSenderImpl.java:501)
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:421)
... 20 common frames omitted
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:331)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:238)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2084)
... 24 common frames omitted
application.yml
mail:
host: "smtp.gmail.com"
port: 465
username: "***#gmail.com"
password: "***"
props:
mail.smtp.auth: "true"
mail.smtp.socketFactory.port: "465"
mail.smtp.socketFactory.class: "javax.net.ssl.SSLSocketFactory"
mail.smtp.socketFactory.fallback: "true"
build.gradle
runtime "org.grails.plugins:mail:2.0.0.RC4"
I have tried also with:
runtime "org.grails.plugins:mail:2.0.0"
runtime "org.grails.plugins:mail:2.0.0.RC6"
and also does not work.
UserController.groovy
package grailsproject
class UserController {
def mailService
def form() {
}
def save() {
def user = new Userr(params)
user.validate()
if(user.hasErrors())
{
user.errors.allErrors.each {
println it
}
render (view:"/registrationForm/registrationForm", model: [user: user]);
}else
{
user.save(flush: true)
render(view: "user", model: [user: user]);
}
mailService.sendMail{
to "***#gmail.com"
from "***#gmail.com"
subject "This is a test mail"
body "Hello, This is a test mail, how are you?"
}
}
}
I do not have idea, what else should I check...
I am also wondering why it try to connect localhost when I gave there gmail host?
Your application.yml should be
grails:
mail:
host: "smtp.gmail.com"
port: 465
username: "your_mail#gmail.com"
password: "Your_password"
props:
mail.smtp.auth: "true"
mail.smtp.socketFactory.port: "465"
mail.smtp.socketFactory.class: "javax.net.ssl.SSLSocketFactory"
mail.smtp.socketFactory.fallback: "false"
build.gradle wiil be
compile "org.grails.plugins:mail:2.0.0.RC6"
UserController.groovy should be
package grailsproject
class UserController {
def index() { }
def send() {
def multipartFile = request.getFile('attachment')
sendMail {
multipart true
to params.address
subject params.subject
html params.body
if(multipartFile && !multipartFile.empty) {
File tmpFile = new File(System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + multipartFile.getOriginalFilename());
multipartFile.transferTo(tmpFile);
attach tmpFile
}
}
flash.message = "Email Sent Successfully"
redirect action:"index"
}
}

Play Mailer plugin with Play 2.5

I am struggling with play mailer plugin. I found many references to configure play-mailer plugin to send email using gmail, but none worked.
Here are the details -
Play 2.5
Scala 2.11
mailer plugin - "com.typesafe.play" %% "play-mailer" % "5.0.0"
And here is my code:
application.conf:
play.mailer {
host="smtp.gmail.com"
port=587
ssl=no
tls=yes
user="pariXXXXXX#gmail.com"
password="XXXXXX"
debug=no
timeout=60
connectiontimeout=60
mock=false
}
Controller:
class HomeController #Inject() (
val messagesApi: MessagesApi,
val mailer:MailerClient)
extends Controller with I18nSupport {
def index = Action {
val bodyHtml = Some(views.html.mails.welcome("Pari").toString)
val email = Email(subject = "subject", from = "pari.XXXXX#gmail.com", to = List("pari.XXXXX#gmail.com"), bodyHtml = bodyHtml, bodyText = Some("Hello"), replyTo = None)
mailer.send(email)
Ok("Did you receive my email?")
}
}
Error:
Execution exception[[EmailException: Sending the email to the following server failed : smtp.gmail.com:587]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:280)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:206)
at play.api.GlobalSettings$class.onError(GlobalSettings.scala:160)
at play.api.DefaultGlobal$.onError(GlobalSettings.scala:188)
at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:98)
at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:100)
at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:99)
at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:344)
at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:343)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:587
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1421)
at org.apache.commons.mail.Email.send(Email.java:1448)
at play.api.libs.mailer.SMTPMailer$$anon$2.send(MailerPlugin.scala:100)
at play.api.libs.mailer.CommonsMailer.send(MailerPlugin.scala:130)
at play.api.libs.mailer.SMTPMailer.send(MailerPlugin.scala:110)
at play.api.libs.mailer.SMTPDynamicMailer.send(MailerPlugin.scala:117)
at controllers.HomeController$$anonfun$index$1.apply(HomeController.scala:82)
at controllers.HomeController$$anonfun$index$1.apply(HomeController.scala:79)
at play.api.mvc.ActionBuilder$$anonfun$apply$14.apply(Action.scala:403)
at play.api.mvc.ActionBuilder$$anonfun$apply$14.apply(Action.scala:403)
Caused by: javax.mail.MessagingException: Exception reading response
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2202)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1939)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1411)
at org.apache.commons.mail.Email.send(Email.java:1448)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:170)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:124)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:89)
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2182)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1939)
Any thoughts?
P.S. I have enabled less secure access for gmail account as well.
You simply need to provide play mailer configuration in your application.conf as below
play.mailer.host= "smtp.gmail.com"
play.mailer.port= "46"
play.mailer.ssl= true
play.mailer.user="pari.XXXX#gmail.com"
play.mailer.password="XXXXXXXXXX"
I have replaced play.mailer block with smtp.mock. After this change I am getting email sent by application.
smtp.mock=false
smtp {
host="smtp.gmail.com" #example:
port="465" #example: 465
ssl=true
user="pari.XXXX#gmail.com"
password="XXXXXXXXXX"
from="XXXXXXX"
}
However, I am getting warning -
smtp is deprecated, use play.mailer instead
Anybody has any idea, how to configure mailer configs.
Thanks
Pari

Using scala-js-env-selenium for crossbrowser testing

I am using https://github.com/scala-js/scala-js-env-selenium for in-browser testing, so far tests are running fine in local browser. Now i want to run my tests in remote browsers (https://app.crossbrowsertesting.com)
I created new CrossBrowser
import org.openqa.selenium.remote.{DesiredCapabilities, RemoteWebDriver}
import org.scalajs.jsenv.selenium.{BrowserDriver, SeleniumBrowser}
import java.net.URL
object CrossBrowser {
def apply(): CrossBrowser = new CrossBrowser
val username = "email"
// Your username
val authkey = "xxxxxxxxxx" // Your authkey
}
class CrossBrowser private() extends SeleniumBrowser {
def name: String = "RemoteBrowser"
def newDriver: BrowserDriver = new CrossDriver
private class CrossDriver extends BrowserDriver {
protected def newDriver(): RemoteWebDriver = {
val caps = new DesiredCapabilities()
caps.setCapability("name", "Selenium Test Example")
caps.setCapability("build", "1.0")
caps.setCapability("browser_api_name", "IE10")
caps.setCapability("os_api_name", "Win7x64-C2")
caps.setCapability("screen_resolution", "1024x768")
caps.setCapability("record_video", "true")
caps.setCapability("record_network", "true")
new RemoteWebDriver(new URL("http://" + CrossBrowser.username + ":" + CrossBrowser.authkey + "#hub.crossbrowsertesting.com:80/wd/hub"), caps)
}
}
}
and updated build settings
jsEnv := new org.scalajs.jsenv.selenium.SeleniumJSEnv(CrossBrowser()),
jsEnv in Test := new org.scalajs.jsenv.selenium.SeleniumJSEnv(CrossBrowser())
when i ran test command i got following output
[trace] Stack trace suppressed: run last client/test:loadedTestFrameworks for the full output.
[error] (client/test:loadedTestFrameworks) org.openqa.selenium.WebDriverException: [fc92901a-f56a-4e4b-9d75-953402cbfe35] Test has timed out after 199 seconds
[error] Command duration or timeout: 199.20 seconds
[error] Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
[error] System info: host: 'Chandras-MacBook-Pro.local', ip: 'xx.xx.xxx.x', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.3', java.version: '1.8.0_25'
[error] Driver info: org.openqa.selenium.remote.RemoteWebDriver
[error] Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=10, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, webdriver.remote.sessionid=fc92901a-f56a-4e4b-9d75-953402cbfe35, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:33793/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
[error] Session ID: fc92901a-f56a-4e4b-9d75-953402cbfe35
Reason for time out is , test-runner tried to load file:/var/folders/n0/c0fyqlqx0gg15mv4t5mchgj80000gn/T/1464125278337-0/scalajsRun.html on remote machine which doesn't exist.
is it possible to do this kind of testing ..?(copy files to some server and load that url ..)
Selenium will need access to your files if you are running local tests. That's usually done via proxies. There seems to be support for local testing though (https://crossbrowsertesting.com/local-testing), you could try to contact them to set this up.