kafka python - Bluemix MessageHub - ConnectionError: socket disconnected - ibm-cloud

I'm using the kafka python client to push messages to Message Hub, but noticed that after a while of running my app that it would stop sending messages to Message Hub.
I then noticed the following in my log files:
ConnectionError: socket disconnected
I updated my code to add retries=5:
from kafka import KafkaProducer
from kafka.errors import KafkaError
import ssl
sasl_mechanism = 'PLAIN'
security_protocol = 'SASL_SSL'
# Create a new context using system defaults, disable all but TLS1.2
context = ssl.create_default_context()
context.options &= ssl.OP_NO_TLSv1
context.options &= ssl.OP_NO_TLSv1_1
producer = KafkaProducer(bootstrap_servers = app.config['KAFKA_BROKERS_SASL'],
sasl_plain_username = app.config['KAFKA_USERNAME'],
sasl_plain_password = app.config['KAFKA_PASSWORD'],
security_protocol = security_protocol,
ssl_context = context,
sasl_mechanism = sasl_mechanism,
api_version = (0,10),
retries=5)
def send_message(message):
try:
producer.send(app.config['KAFKA_TOPIC'], message.encode('utf-8'))
# FIXME sending seems to be unreliable unless we flush
producer.flush()
except:
print("Unexpected error:", sys.exc_info()[0])
raise
My code runs from a python flask app. Every request of a certain type that comes in calls the send_message() method.
Here are the relevant log lines from Bluemix. I may have missed a line or two copying and pasting, but hopefully it is enough to figure out what is happening:
APP/1 <BrokerConnection host=kafka01-prod01.messagehub.services.us-south.bluemix.net/23.246.202.51 port=9093>: Authenticated as xxxxx May 15, 2017 8:50:54 PM
APP/1 <BrokerConnection host=kafka01-prod01.messagehub.services.us-south.bluemix.net/23.246.202.51 port=9093>: socket disconnected May 15, 2017 8:50:54 PM
APP/1 Got error produce response on topic-partition TopicPartition(topic='movie_ratings', partition=0), retrying (4 attempts left). Error: ConnectionError: socket disconnectedMay 15, 2017 8:50:54 PM
APP/1 Node 0 connection failed -- refreshing metadata May 15, 2017 8:50:54 PM
APP/1 <BrokerConnection host=kafka01-prod01.messagehub.services.us-south.bluemix.net/23.246.202.51 port=9093>: Authenticated as xxxxxMay 15, 2017 8:50:54 PM
APP/1 <BrokerConnection host=kafka01-prod01.messagehub.services.us-south.bluemix.net/23.246.202.51 port=9093>: socket disconnected May 15, 2017 8:50:54 PM
APP/1 Node 0 connection failed -- refreshing metadata May 15, 2017 8:50:54 PM
APP/1 <BrokerConnection host=kafka01-prod01.messagehub.services.us-south.bluemix.net/23.246.202.51 port=9093>: Authenticated as xxxxx May 15, 2017 8:50:54 PM
APP/1 <BrokerConnection host=kafka01-prod01.messagehub.services.us-south.bluemix.net/23.246.202.51 port=9093>: socket disconnected May 15, 2017 8:50:55 PM
APP/1 Node 0 connection failed -- refreshing metadata May 15, 2017 8:50:55 PM
APP/1 Got error produce response on topic-partition TopicPartition(topic='movie_ratings', partition=0), retrying (2 attempts left). Error: ConnectionError: socket disconnected May 15, 2017 8:50:55 PM
APP/1 <BrokerConnection host=kafka01-prod01.messagehub.services.us-south.bluemix.net/23.246.202.51 port=9093>: Authenticated as xxxxx May 15, 2017 8:50:55 PM
APP/1 <BrokerConnection host=kafka01-prod01.messagehub.services.us-south.bluemix.net/23.246.202.51 port=9093>: socket disconnected May 15, 2017 8:50:55 PM
APP/1 Node 0 connection failed -- refreshing metadata May 15, 2017 8:50:55 PM
APP/1 Got error produce response on topic-partition TopicPartition(topic='movie_ratings', partition=0), retrying (1 attempts left). Error: ConnectionError: socket disconnected May 15, 2017 8:50:55 PM
APP/1 <BrokerConnection host=kafka01-prod01.messagehub.services.us-south.bluemix.net/23.246.202.51 port=9093>: Authenticated as xxxxx May 15, 2017 8:50:55 PM
APP/1 <BrokerConnection host=kafka01-prod01.messagehub.services.us-south.bluemix.net/23.246.202.51 port=9093>: socket disconnected May 15, 2017 8:50:55 PM
APP/1 Got error produce response on topic-partition TopicPartition(topic='movie_ratings', partition=0), retrying (0 attempts left). Error: ConnectionError: socket disconnected May 15, 2017 8:50:55 PM
APP/1 Node 0 connection failed -- refreshing metadata May 15, 2017 8:50:55 PM
APP/1 <BrokerConnection host=kafka01-prod01.messagehub.services.us-south.bluemix.net/23.246.202.51 port=9093>: Authenticated as xxxxx May 15, 2017 8:50:55 PM
APP/1 Node 0 connection failed -- refreshing metadata May 15, 2017 8:50:56 PM
APP/1 ConnectionError: socket disconnected May 15, 2017 8:50:56 PM
APP/1 Unable to import 'sasl'. Fallback to 'puresasl'. May 15, 2017 8:51:00 PM
APP/1 Closing active operation May 15, 2017 8:51:01 PM
My topic exists. My full client code is here: https://github.com/snowch/movie-recommender-demo/blob/effc981cc9f799c41952719619f693172eebcd6a/web_app/app/messagehub_client.py
Any pointers most appreciated ...

As per Dominic's comment, upgrading kafka python to 1.3.3 fixed the issue for me.

Related

Why does Eclipse sometimes hang when my program connects to JBoss

Sometimes when I run my project, that connects to JBoss, it will hang.
For example here is the log output for when it hangs:
Dec 14, 2021 11:57:58 AM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 1.0.5.Final
Dec 14, 2021 11:57:58 AM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
Dec 14, 2021 11:57:58 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
Dec 14, 2021 11:57:58 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.3.GA
Dec 14, 2021 11:57:58 AM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: Received server version 2 and marshalling strategies [river]
Dec 14, 2021 11:57:58 AM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#29f5ca0b, receiver=Remoting connection EJB receiver [connection=Remoting connection <71c88986>,channel=jboss.ejb,nodename=DevApp00:DevApp00]} on channel Channel ID ec955d48 (outbound) of Remoting connection 04a8743d to devapp00.magcore.XXXXXXXXXXXXX.com/XX.XX.XX.XXX:XXXX
Dec 14, 2021 11:57:59 AM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: Received server version 2 and marshalling strategies [river]
Dec 14, 2021 11:57:59 AM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#29f5ca0b, receiver=Remoting connection EJB receiver [connection=Remoting connection <6d5bcb39>,channel=jboss.ejb,nodename=DevApp01:DevApp01]} on channel Channel ID c9163bbe (outbound) of Remoting connection 50ba181a to devapp01.magcore.XXXXXXXXXXXXX.com/XX.XX.XX.XXX:XXXX
Dec 14, 2021 11:57:59 AM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: Received server version 2 and marshalling strategies [river]
Dec 14, 2021 11:57:59 AM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#29f5ca0b, receiver=Remoting connection EJB receiver [connection=Remoting connection <7900f3c9>,channel=jboss.ejb,nodename=DevApp01:DevApp01]} on channel Channel ID aa5e4733 (outbound) of Remoting connection 6075ef24 to /XX.XX.XX.XXX:XXXX
Here is the log output when it doesn't hang:
Dec 14, 2021 11:58:42 AM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 1.0.5.Final
Dec 14, 2021 11:58:42 AM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
Dec 14, 2021 11:58:42 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
Dec 14, 2021 11:58:42 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.3.GA
Dec 14, 2021 11:58:43 AM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: Received server version 2 and marshalling strategies [river]
Dec 14, 2021 11:58:43 AM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#4ae0a5dc, receiver=Remoting connection EJB receiver [connection=Remoting connection <71ed5401>,channel=jboss.ejb,nodename=DevApp00:DevApp00]} on channel Channel ID b0b91086 (outbound) of Remoting connection 11244593 to devapp00.magcore.XXXXXXXXXXXXX.com/XX.XX.XX.XXX:XXXX
Dec 14, 2021 11:58:43 AM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: Received server version 2 and marshalling strategies [river]
Dec 14, 2021 11:58:43 AM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#4ae0a5dc, receiver=Remoting connection EJB receiver [connection=Remoting connection <3f7dbbe3>,channel=jboss.ejb,nodename=DevApp01:DevApp01]} on channel Channel ID a49da456 (outbound) of Remoting connection 7900f3c9 to devapp01.magcore.XXXXXXXXXXXXX.com/XX.XX.XX.XXX:XXXX
Dec 14, 2021 11:58:43 AM org.jboss.ejb.client.ClusterContext registerEJBReceiver
INFO: Added a new EJB receiver in cluster context ejb for node DevApp01:DevApp01. Total nodes in cluster context = 1
Dec 14, 2021 11:58:43 AM org.jboss.ejb.client.ClusterContext registerEJBReceiver
INFO: Added a new EJB receiver in cluster context ejb for node DevApp00:DevApp00. Total nodes in cluster context = 2
Here is my jboss-ejb-client.properties
endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
invocation.timeout=3000
reconnect.tasks.timeout=2000
remote.connections=dev1,dev2
remote.clusters=ejb
# Dev1 - Node 1
remote.connection.dev1.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.dev1.connect.options.org.jboss.remoting3.RemotingOptions.HEARTBEAT_INTERVAL=300000
remote.connection.dev1.host=devapp00.magcore.XXXXXXXXXXXXX.com
remote.connection.dev1.port=XXXX
remote.connection.dev1.username=XXXXXXXXXX
remote.connection.dev1.password=XXXXXXXXXX
# Dev2 - Node 2
remote.connection.dev2.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.dev2.connect.options.org.jboss.remoting3.RemotingOptions.HEARTBEAT_INTERVAL=300000
remote.connection.dev2.host=devapp01.magcore.XXXXXXXXXXXXX.com
remote.connection.dev2.port=XXXX
remote.connection.dev2.username=XXXXXXXXXX
remote.connection.dev2.password=XXXXXXXXXX
# cluster 1
remote.cluster.ejb.connect.timeout=2500
remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.cluster.ejb.connect.options.org.xnio.Options.SSL_ENABLED=false
remote.cluster.ejb.username=XXXXXXXXXX
#Dev Password
remote.cluster.ejb.password=XXXXXXXXXX
This morning I tried 26 times and is hung every time, but it doesn't always hang.
If I deploy this via WebStart, it seems to work just fine.
Interestingly, it seems as if it is hanging on setting up the cluster. I don't know why I didn't see this before, but it doesn't really help me solve the problem.

AWS Glue not able to access database in VPC

I have AWS Glue Job which is using Spark and Scala with jdbc connections specified in the script for custom ETL and data decryption. While running the job in an environment where databases are not publicly available the jobs are failing with communication failure. I have the Glue and S3 Endpoints defined in the same VPC as the database but still no success.
Also tried creating a fake connection and a Network connection but after adding the connection to the job, the job never finishes and is stuck.
Jun 22, 2021, 7:46:47 AM 21/06/22 14:46:47 WARN ApacheUtils: NoSuchMethodException was thrown when disabling normalizeUri. This indicates you are using an old version (< 4.5.8) of Apache http client. It is recommended to use http client version >= 4.5.9 to avoid the breaking change introduced in apache client 4.5.7 and the latency in exception handling. See https://github.com/aws/aws-sdk-java/issues/1919 for more information
Jun 22, 2021, 7:46:48 AM 21/06/22 14:46:48 INFO Utils: Successfully started service 'sparkDriver' on port 37917.
Jun 22, 2021, 7:46:50 AM 21/06/22 14:46:50 INFO GlueContext: GlueMetrics configured and enabled
Jun 22, 2021, 7:47:48 AM 21/06/22 14:47:48 WARN EC2MetadataUtils: Unable to retrieve the requested metadata (/latest/user-data/). The requested metadata is not found at http://169.254.169.254/latest/user-data/
Jun 22, 2021, 7:47:48 AM 21/06/22 14:47:48 ERROR UserData: Error encountered while try to get user data
Jun 22, 2021, 7:47:48 AM 21/06/22 14:47:48 INFO MultipartUploadOutputStream: close closed:false s3://{{bucket}}/spark/spark-application-1624373208897.inprogress
Jun 22, 2021, 7:48:47 AM 21/06/22 14:48:47 INFO MultipartUploadOutputStream: close closed:false s3://{{bucket}}/spark/spark-application-1624373208897.inprogress
Jun 22, 2021, 7:49:47 AM 21/06/22 14:49:47 INFO MultipartUploadOutputStream: close closed:false s3://{{bucket}}/spark/spark-application-1624373208897.inprogress
Jun 22, 2021, 7:50:47 AM 21/06/22 14:50:47 INFO MultipartUploadOutputStream: close closed:false s3://{{bucket}}/spark/spark-application-1624373208897.inprogress
Jun 22, 2021, 7:51:47 AM 21/06/22 14:51:47 INFO MultipartUploadOutputStream: close closed:false s3://{{bucket}}/spark/spark-application-1624373208897.inprogress
Jun 22, 2021, 7:52:47 AM 21/06/22 14:52:47 INFO MultipartUploadOutputStream: close closed:false s3://{{bucket}}/spark/spark-application-1624373208897.inprogress
Without Connection
Jun 21, 2021, 8:29:12 PM 21/06/22 03:29:12 ERROR ProcessLauncher: InvocationTargetException java.lang.reflect.InvocationTargetException
Jun 21, 2021, 8:29:12 PM 21/06/22 03:29:12 ERROR ProcessLauncher: Exception in User Class
Jun 21, 2021, 8:29:12 PM 21/06/22 03:29:12 ERROR ProcessLauncher: Exception in User Class: com.mysql.cj.jdbc.exceptions.CommunicationsException : Communications link failure com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836) com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456) com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:63) org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:54) org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:56) org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation$.getSchema(JDBCRelation.scala:210) org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:35) org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:318)```

SASL authentication failed using login context 'Client'

I am working in securing Kafka with Kerberos in CDH 5.5
Kafka version: 2.0.1
Kerberos is enabled and works fine
when i enable sasl in kafka using cloudera maneger, i get the error:
Jun 29, 3:02:42.875 PM INFO org.apache.zookeeper.ClientCnxn
Opening socket connection to server brahim.localhost/127.0.0.1:2181. Will attempt to SASL-authenticate using Login Context section 'Client'
Jun 29, 3:02:42.879 PM INFO org.apache.zookeeper.ClientCnxn
Socket connection established to brahim.localhost/127.0.0.1:2181, initiating session
Jun 29, 3:02:42.906 PM INFO org.apache.zookeeper.ClientCnxn
Session establishment complete on server brahim.localhost/127.0.0.1:2181, sessionid = 0x1559c20b6110007, negotiated timeout = 30000
Jun 29, 3:02:42.910 PM INFO org.I0Itec.zkclient.ZkClient
zookeeper state changed (SyncConnected)
Jun 29, 3:02:42.942 PM ERROR org.apache.zookeeper.client.ZooKeeperSaslClient
SASL authentication failed using login context 'Client'.
Jun 29, 3:02:42.942 PM INFO org.I0Itec.zkclient.ZkClient
zookeeper state changed (AuthFailed)
Jun 29, 3:02:48.551 PM INFO org.I0Itec.zkclient.ZkEventThread
Terminate ZkClient event thread.
Jun 29, 3:02:48.554 PM FATAL kafka.Kafka$
org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 6000
at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:1223)
at org.I0Itec.zkclient.ZkClient.(ZkClient.java:155)
at org.I0Itec.zkclient.ZkClient.(ZkClient.java:129)
at kafka.utils.ZkUtils$.createZkClientAndConnection(ZkUtils.scala:80)
at kafka.utils.ZkUtils$.apply(ZkUtils.scala:62)
at nl.techop.kafka.dao.zookeeper.KafkaZkClient.(KafkaZkClient.scala:52)
at nl.techop.kafka.KafkaHttpMetricsServer.init(KafkaHttpMetricsServer.scala:43)
at nl.techop.kafka.KafkaHttpMetricsServer.(KafkaHttpMetricsServer.scala:28)
at nl.techop.kafka.KafkaHttpMetricsReporter.init(KafkaHttpMetricsReporter.scala:41)
at kafka.metrics.KafkaMetricsReporter$$anonfun$startReporters$1.apply(KafkaMetricsReporter.scala:60)
at kafka.metrics.KafkaMetricsReporter$$anonfun$startReporters$1.apply(KafkaMetricsReporter.scala:58)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:35)
at kafka.metrics.KafkaMetricsReporter$.startReporters(KafkaMetricsReporter.scala:58)
at kafka.server.KafkaServerStartable$.fromProps(KafkaServerStartable.scala:27)
at kafka.Kafka$.main(Kafka.scala:58)
at com.cloudera.kafka.wrap.Kafka$.main(Kafka.scala:76)
at com.cloudera.kafka.wrap.Kafka.main(Kafka.scala)
Regenerating keytabs for zookeeper and kafka solved my problem

RemoteException in connecting to Tomee (OpenEJB)

Working from the hello world sample, what can I do on tleilax to allow doge to connect to the locally running OpenEJB server? I've read through the documentation on how startup OpenEJB, but must be missing a step from the manual.
On tleilax, deploying Hello.jar:
thufir#tleilax:~$ openejb deploy Hello.jar
Mar 07, 2015 10:34:30 PM org.apache.openejb.client.EventLogger log
INFO: RemoteInitialContextCreated{providerUri=ejbd://localhost:4201}
Mar 07, 2015 10:34:31 PM org.apache.openejb.client.EventLogger log
INFO: ConnectionOpened{uri=ejbd://localhost:4201}
Mar 07, 2015 10:34:31 PM org.apache.openejb.client.EventLogger log
INFO: ServerAdded{server=ejbds://127.0.0.1:4203} ClusterMetaDataUpdated{provider=ejbd://localhost:4201, version=1425796337772, uris=2}
Mar 07, 2015 10:34:31 PM org.apache.openejb.client.EventLogger log
INFO: ServerAdded{server=ejbd://127.0.0.1:4201} ClusterMetaDataUpdated{provider=ejbd://localhost:4201, version=1425796337772, uris=2}
Mar 07, 2015 10:34:31 PM org.apache.openejb.client.EventLogger log
INFO: ServerRemoved{server=ejbd://localhost:4201} ClusterMetaDataUpdated{provider=ejbd://localhost:4201, version=1425796337772, uris=2}
Application deployed successfully at "Hello.jar"
App(id=/home/thufir/apache-openejb-4.7.1/apps/Hello.jar)
EjbJar(id=Hello, path=/home/thufir/apache-openejb-4.7.1/apps/Hello.jar)
Ejb(ejb-name=HelloBean, id=HelloBean)
Jndi(name=HelloBeanRemote)
Jndi(name=global/Hello/HelloBean!org.acme.Hello)
Jndi(name=global/Hello/HelloBean)
some output from tleilax openejb showing the deploy:
INFO: OpenWebBeans Container has started, it took 241 ms.
Mar 07, 2015 10:34:32 PM org.apache.openejb.assembler.classic.Assembler startEjbs
INFO: Created Ejb(deployment-id=HelloBean, ejb-name=HelloBean, container=My Stateless Container)
Mar 07, 2015 10:34:32 PM org.apache.openejb.assembler.classic.Assembler startEjbs
INFO: Started Ejb(deployment-id=HelloBean, ejb-name=HelloBean, container=My Stateless Container)
Mar 07, 2015 10:34:32 PM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Deployed Application(path=/home/thufir/apache-openejb-4.7.1/apps/Hello.jar)
scanning tleilax for open ports:
thufir#doge:~$
thufir#doge:~$ nmap 192.168.1.3
Starting Nmap 6.46 ( http://nmap.org ) at 2015-03-07 22:42 PST
Nmap scan report for 192.168.1.3
Host is up (0.00092s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
119/tcp open nntp
Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
thufir#doge:~$
the bound services on tleilax:
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager start
INFO: ** Bound Services **
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO: NAME IP PORT
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO: httpejbd 127.0.0.1 4204
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO: multipoint 127.0.0.1 4212
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO: admin 127.0.0.1 4200
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO: ejbd 127.0.0.1 4201
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO: multicast 239.255.2.3 6142
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO: ejbds 127.0.0.1 4203
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO: multipulse 239.255.2.3 6142
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager start
INFO: -------
Mar 07, 2015 10:32:17 PM org.apache.openejb.server.SimpleServiceManager start
INFO: Ready!
So, the server is ready on tleilax. Why can't the client connect properly?
thufir#doge:~$
thufir#doge:~$ java -classpath .:NetBeansProjects/HelloClient/dist/HelloClient.jar:apache-openejb-4.7.1/lib/openejb-client-4.7.1.jar:netbeans-8.0.2/enterprise/modules/ext/javaee-api-7.0.jar org.acme.HelloClient
Mar 07, 2015 10:49:46 PM org.apache.openejb.client.EventLogger log
INFO: RemoteInitialContextCreated{providerUri=ejbd://192.168.1.3:4201}
Mar 07, 2015 10:49:46 PM org.apache.openejb.client.EventLogger log
WARNING: ConnectionFailed{uri=ejbd://192.168.1.3:4201 cause=java.io.IOException: Cannot connect to server 'ejbd://192.168.1.3:4201'. Check that the server is started and that the specified serverURL is correct.}
Mar 07, 2015 10:49:46 PM org.apache.openejb.client.EventLogger log
WARNING: BootstrappingConnection{provider=ejbd://192.168.1.3:4201}
Mar 07, 2015 10:49:46 PM org.apache.openejb.client.EventLogger log
WARNING: ConnectionFailed{uri=ejbd://192.168.1.3:4201 cause=java.io.IOException: Cannot connect to server 'ejbd://192.168.1.3:4201'. Check that the server is started and that the specified serverURL is correct.}
Mar 07, 2015 10:49:46 PM org.apache.openejb.client.EventLogger log
SEVERE: ConnectionStrategyFailed{strategy=StickyConnectionStrategy, cluster=org.apache.openejb.client.ClusterMetaData#7d261f7f, server=ejbd://192.168.1.3:4201}
Exception in thread "main" javax.naming.NamingException: Cannot lookup '/HelloBeanRemote'. [Root exception is java.rmi.RemoteException: Unable to connect; nested exception is:
java.io.IOException: Cannot connect to server 'ejbd://192.168.1.3:4201'. Check that the server is started and that the specified serverURL is correct.]
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:405)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.acme.HelloClient.main(HelloClient.java:16)
Caused by: java.rmi.RemoteException: Unable to connect; nested exception is:
java.io.IOException: Cannot connect to server 'ejbd://192.168.1.3:4201'. Check that the server is started and that the specified serverURL is correct.
at org.apache.openejb.client.Client.processRequest(Client.java:167)
at org.apache.openejb.client.Client.request(Client.java:141)
at org.apache.openejb.client.JNDIContext.request(JNDIContext.java:211)
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:399)
... 2 more
Caused by: java.io.IOException: Cannot connect to server 'ejbd://192.168.1.3:4201'. Check that the server is started and that the specified serverURL is correct.
at org.apache.openejb.client.SocketConnectionFactory$SocketConnection.failure(SocketConnectionFactory.java:334)
at org.apache.openejb.client.SocketConnectionFactory$SocketConnection.open(SocketConnectionFactory.java:308)
at org.apache.openejb.client.SocketConnectionFactory.getConnection(SocketConnectionFactory.java:162)
at org.apache.openejb.client.ConnectionManager.getConnection(ConnectionManager.java:112)
at org.apache.openejb.client.AbstractConnectionStrategy.connect(AbstractConnectionStrategy.java:105)
at org.apache.openejb.client.AbstractConnectionStrategy.connect(AbstractConnectionStrategy.java:81)
at org.apache.openejb.client.ConnectionManager.getConnection(ConnectionManager.java:88)
at org.apache.openejb.client.Client.processRequest(Client.java:165)
... 5 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at org.apache.openejb.client.SocketConnectionFactory$SocketConnection.open(SocketConnectionFactory.java:300)
... 11 more
thufir#doge:~$
thufir#doge:~$
For what it's worth, I checked that the HelloClient runs locally from tleilax fine:
thufir#tleilax:~$
thufir#tleilax:~$ java -classpath .:HelloClient.jar:apache-openejb-4.7.1/lib/openejb-client-4.7.1.jar:netbeans-8.0.2/enterprise/modules/ext/javaee-api-7.0.jar org.acme.HelloClient
Mar 07, 2015 10:56:46 PM org.apache.openejb.client.EventLogger log
INFO: RemoteInitialContextCreated{providerUri=ejbd://127.0.0.1:4201}
Mar 07, 2015 10:56:46 PM org.apache.openejb.client.EventLogger log
INFO: ConnectionOpened{uri=ejbd://127.0.0.1:4201}
Mar 07, 2015 10:56:46 PM org.apache.openejb.client.EventLogger log
INFO: ServerAdded{server=ejbds://127.0.0.1:4203} ClusterMetaDataUpdated{provider=ejbd://127.0.0.1:4201, version=1425796337772, uris=2}
Hello World!!!!
thufir#tleilax:~$
Of course, the client running locally on tleilax connects to 127.0.0.1, while the client on doge connects, or tries to connect, to the ip adress for tleilax: 192.168.1.3; the ip address is hardcoded in the sample.

JBoss Cluster EJB Remoting

I currently have a JBoss instance running with standalone-ha.xml as the config file. JBoss 7.1.1 Final. I have deployed a basic HelloBean inside a .jar called ClusterTestEJB inside an .ear called ClusterTest.
HelloBean:
package com.sample;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import org.jboss.ejb3.annotation.Clustered;
#Stateless
#Clustered
#Remote
public class HelloBean implements HelloBeanItf {
int counter = 0;
public String doSomething() {
return "HelloBean Called";
}
}
The HelloBeanItf is as follows:
package com.sample;
public interface HelloBeanItf {
public String doSomething();
}
I got the code from a tutorial I was following.
So I have everything seemingly working. I am now trying to write a java client to invoke that EJB. Here is that code:
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.sample.HelloBeanItf;
public class Client {
public static void main(String[] args){
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
p.put("jboss.naming.client.ejb.context", true);
p.put(Context.SECURITY_PRINCIPAL, "user");
p.put(Context.SECURITY_CREDENTIALS, "password");
p.put(Context.PROVIDER_URL, "remote://mynode:4447");
InitialContext ctx;
try {
ctx = new InitialContext(p);
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
}
HelloBeanItf ejb = null;
try {
ejb = (HelloBeanItf) ctx.lookup("java:ClusterTest/ClusterTestEJB//HelloBean!com.sample.HelloBeanItf");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
}
for (int ii=0;ii<10;ii++) {
ejb.doSomething();
}
System.out.println("Terminated");
}
}
Here is client side log output:
Bad level value for property: java.util.logging.ConsoleHandler.level
Apr 03, 2014 10:49:30 PM org.jboss.logging.LoggerProviders find
DEBUG: Logging Provider: org.jboss.logging.JDKLoggerProvider
Apr 03, 2014 10:49:30 PM org.jboss.naming.remote.client.InitialContextFactory findClientProperties
DEBUG: Looking for jboss-naming-client.properties using classloader sun.misc.Launcher$AppClassLoader#6921dcac
Apr 03, 2014 10:49:30 PM org.jboss.naming.remote.client.InitialContextFactory getOptionMapFromProperties
DEBUG: jboss.naming.client.endpoint.create.options. has the following options {}
Apr 03, 2014 10:49:30 PM org.jboss.naming.remote.client.InitialContextFactory getOptionMapFromProperties
DEBUG: jboss.naming.client.remote.connectionprovider.create.options. has the following options {}
Apr 03, 2014 10:49:30 PM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
Apr 03, 2014 10:49:30 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
Apr 03, 2014 10:49:30 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.3.GA
Apr 03, 2014 10:49:30 PM org.xnio.nio.WorkerThread run
DEBUG: Started channel thread 'Remoting "config-based-naming-client-endpoint" read-1', selector sun.nio.ch.WindowsSelectorImpl#3a151cc3
Apr 03, 2014 10:49:30 PM org.xnio.nio.WorkerThread run
DEBUG: Started channel thread 'Remoting "config-based-naming-client-endpoint" write-1', selector sun.nio.ch.WindowsSelectorImpl#42d2821b
Apr 03, 2014 10:49:30 PM org.jboss.naming.remote.client.InitialContextFactory getOptionMapFromProperties
DEBUG: jboss.naming.client.connect.options. has the following options {}
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.EJBClientPropertiesLoader loadEJBClientProperties
DEBUG: Looking for jboss-ejb-client.properties using classloader sun.misc.Launcher$AppClassLoader#6921dcac
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector <init>
DEBUG: EJB client context org.jboss.ejb.client.EJBClientContext#51bc1897 will have no EJB receivers associated with it since there was no EJB client configuration available to create the receivers
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver$1 handleDone
DEBUG: Channel Channel ID 828f699b (outbound) of Remoting connection 0d818ff0 to node1-w7.wv-lab.mentorg.com/139.181.88.6:4447 opened for context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#7c572f78, receiver=Remoting connection EJB receiver [connection=Remoting connection <6981170d>,channel=jboss.ejb,nodename=node1]} Waiting for version handshake message from server
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: Received server version 1 and marshalling strategies [river]
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#7c572f78, receiver=Remoting connection EJB receiver [connection=Remoting connection <6981170d>,channel=jboss.ejb,nodename=node1]} on channel Channel ID 828f699b (outbound) of Remoting connection 0d818ff0 to node1-w7.wv-lab.mentorg.com/139.181.88.6:4447
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver modulesAvailable
DEBUG: Received module availability report for 3 modules
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver modulesAvailable
DEBUG: Registering module EJBModuleIdentifier{appName='', moduleName='ClusterWebApp', distinctName=''} availability for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#7c572f78, receiver=Remoting connection EJB receiver [connection=Remoting connection <6981170d>,channel=jboss.ejb,nodename=node1]}
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver modulesAvailable
DEBUG: Registering module EJBModuleIdentifier{appName='ClusterTest', moduleName='ClusterTest', distinctName=''} availability for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#7c572f78, receiver=Remoting connection EJB receiver [connection=Remoting connection <6981170d>,channel=jboss.ejb,nodename=node1]}
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver modulesAvailable
DEBUG: Registering module EJBModuleIdentifier{appName='ClusterTest', moduleName='ClusterTestEJB', distinctName=''} availability for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#7c572f78, receiver=Remoting connection EJB receiver [connection=Remoting connection <6981170d>,channel=jboss.ejb,nodename=node1]}
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.ClusterNode resolveDestination
DEBUG: Checking for a match of client address /fe80:0:0:0:0:5efe:ac1e:5010%14 with client mapping ClientMapping{sourceNetworkAddress=/0:0:0:0:0:0:0:0, sourceNetworkMaskBits=0, destinationAddress='139.181.88.6', destinationPort=4447}
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.ClusterNode resolveDestination
DEBUG: Client mapping ClientMapping{sourceNetworkAddress=/0:0:0:0:0:0:0:0, sourceNetworkMaskBits=0, destinationAddress='139.181.88.6', destinationPort=4447} matches client address /fe80:0:0:0:0:5efe:ac1e:5010%14
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.remoting.ClusterTopologyMessageHandler processMessage
DEBUG: Received a cluster node(s) addition message, for cluster named ejb with 1 nodes [ClusterNode{clusterName='ejb', nodeName='node1', clientMappings=[ClientMapping{sourceNetworkAddress=/0:0:0:0:0:0:0:0, sourceNetworkMaskBits=0, destinationAddress='139.181.88.6', destinationPort=4447}], resolvedDestination=[Destination address=139.181.88.6, destination port=4447]}]
Apr 03, 2014 10:49:32 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver
DEBUG: org.jboss.ejb.client.RandomDeploymentNodeSelector#5254e73f deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname=
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver
DEBUG: org.jboss.ejb.client.RandomDeploymentNodeSelector#5254e73f deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname=
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver
DEBUG: org.jboss.ejb.client.RandomDeploymentNodeSelector#5254e73f deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname=
Apr 03, 2014 10:49:33 PM org.jboss.remoting3.remote.ClientConnectionOpenListener$Authentication$1 run
DEBUG: Client authentication failed for mechanism DIGEST-MD5: javax.security.sasl.SaslException: DIGEST-MD5: Cannot perform callback to acquire realm, authentication ID or password [Caused by javax.security.auth.callback.UnsupportedCallbackException]
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver
DEBUG: org.jboss.ejb.client.RandomDeploymentNodeSelector#5254e73f deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname=
Apr 03, 2014 10:49:33 PM org.jboss.remoting3.remote.RemoteConnection handleException
ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.remoting.RemotingConnectionClusterNodeManager getEJBReceiver
INFO: Could not create a connection for cluster node ClusterNode{clusterName='ejb', nodeName='node1', clientMappings=[ClientMapping{sourceNetworkAddress=/0:0:0:0:0:0:0:0, sourceNetworkMaskBits=0, destinationAddress='139.181.88.6', destinationPort=4447}], resolvedDestination=[Destination address=139.181.88.6, destination port=4447]} in cluster ejb
java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:91)
at org.jboss.ejb.client.remoting.RemotingConnectionClusterNodeManager.getEJBReceiver(RemotingConnectionClusterNodeManager.java:117)
at org.jboss.ejb.client.ClusterContext$EJBReceiverAssociationTask.run(ClusterContext.java:333)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:365)
at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:214)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)
at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189)
at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)
at org.xnio.nio.NioHandle.run(NioHandle.java:90)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:184)
at ...asynchronous invocation...(Unknown Source)
at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:270)
at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:251)
at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:349)
at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:333)
at org.jboss.ejb.client.remoting.RemotingConnectionClusterNodeManager.getEJBReceiver(RemotingConnectionClusterNodeManager.java:115)
... 6 more
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver
DEBUG: org.jboss.ejb.client.RandomDeploymentNodeSelector#5254e73f deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname=
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver
DEBUG: org.jboss.ejb.client.RandomDeploymentNodeSelector#5254e73f deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname=
Apr 03, 2014 10:49:33 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver
DEBUG: org.jboss.ejb.client.RandomDeploymentNodeSelector#5254e73f deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname=
Apr 03, 2014 10:49:34 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver
DEBUG: org.jboss.ejb.client.RandomDeploymentNodeSelector#5254e73f deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname=
Apr 03, 2014 10:49:34 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver
DEBUG: org.jboss.ejb.client.RandomDeploymentNodeSelector#5254e73f deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname=
Apr 03, 2014 10:49:34 PM org.jboss.ejb.client.EJBClientContext getEJBReceiver
DEBUG: org.jboss.ejb.client.RandomDeploymentNodeSelector#5254e73f deployment node selector selected node1 node for appname=ClusterTest,modulename=ClusterTestEJB,distinctname=
Terminated
I have tried the following:
Removing the remoting security realm, removing the username and password. I am not sure what else to try at this point.
First time poster, so let me know if more details are needed or if you have questions.
Thanks for the help!
For the record, the inability to execute the EJB was fixed by upgrading from 7.1.1. to 7.1.3. After the upgrade, I was still getting the SASL exception, but the EJB was executing successfully.
The SASL exception was resolved by switching to using the ejb-client instead of the remote-naming libraries and adding clustering properties. Remote naming does not do load balancing anyway, so the switch was necessary for me.