while running Rabbit mqqt getting error - rabbitmq
I have copied rabbit mqqt code from one article.
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
public class MqttPublishSample {
public static void main(String[] args) {
String topic = "MQTT Examples";
String content = "Message from MqttPublishSample";
int qos = 0;
String broker = "tcp://127.0.0.1:1883";
String clientId = "pahomqttpublish1";
try {
MqttClient sampleClient = new MqttClient(broker, clientId);
MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setUserName("guest");
connOpts.setPassword("guest".toCharArray());
connOpts.setCleanSession(true);
System.out.println("Connecting to broker: " + broker);
sampleClient.connect(connOpts);
System.out.println("Connected");
System.out.println("Publishing message: " + content);
MqttMessage message = new MqttMessage(content.getBytes());
message.setQos(qos);
sampleClient.publish(topic, message);
System.out.println("Message published");
sampleClient.disconnect();
System.out.println("Disconnected");
System.exit(0);
} catch (MqttException me) {
System.out.println("reason " + me.getReasonCode());
System.out.println("msg " + me.getMessage());
System.out.println("loc " + me.getLocalizedMessage());
System.out.println("cause " + me.getCause());
System.out.println("excep " + me);
me.printStackTrace();
}
}
}
Getting error while running this code this not Qos issue
error while connecting sampleClient.connect(connOpts);
**Error on console **
Connecting to broker: tcp://127.0.0.1:1883
reason 32109
msg Connection lost
loc Connection lost
cause java.io.EOFException
excep Connection lost (32109) - java.io.EOFException
Connection lost (32109) - java.io.EOFException atrg.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146) at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:267) at rg.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65) at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)
Rabbitmq error log
=ERROR REPORT==== 19-Aug-2016::17:24:54 ===
** Generic server <0.469.0> terminating
** Last message in was
{inet_async,#Port<0.12379>,4714,{ok,[16,42,0,4,77,81,84,84,4,194,0,60,0,16,112,97,104,111,109,113,116,116,112,117,98,108,105,
115,104,49,0,5,103,117,101,115,116,0,5,103,117,101,115,116]}}`
** When Server state == {state,#Port<0.12379>,"127.0.0.1:34033 -> 127.0.0.1:1883",true,running,false,none,{proc_state,#Port<0.12379>,
{dict,0,16,16,8,80,48,{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},{{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}},
{undefined,undefined},{0,nil},{0,nil},undefined,1,undefined,undefined,undefined,{undefined,undefined},undefined,<<"amq.topic">>}}
Reason for termination ==
{{badfun,none},[{rabbit_mqtt_frame,parse,2,[{file,"rabbitmq-mqtt/src/rabbit_mqtt_frame.erl"},{line,39}]},
{rabbit_mqtt_reader,process_received_bytes,2,[{file,"rabbitmq-mqtt/src/rabbit_mqtt_reader.erl"},{line,136}]},{gen_server2,handle_msg,2,[{file,"src/gen_server2.erl"},{line,934}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]}
I think you have installed Rabitmq 3.2.5 through apt-get, please install new version of rabitmq 3.6.5 find here here then try
Related
Ktor-server-test-host did not cleaned up Exposed database instannce across tests
I'm working on a web service using Ktor 1.6.8 and Exposed 0.39.2. My application module and database is setup as following: fun Application.module(testing: Boolean = false) { val hikariConfig = HikariConfig().apply { driverClassName = "org.postgresql.Driver" jdbcUrl = environment.config.propertyOrNull("ktor.database.url")?.getString() username = environment.config.propertyOrNull("ktor.database.username")?.getString() password = environment.config.propertyOrNull("ktor.database.password")?.getString() maximumPoolSize = 10 isAutoCommit = false transactionIsolation = "TRANSACTION_REPEATABLE_READ" validate() } val pool = HikariDataSource(hikariConfig) val db = Database.connect(pool, {}, DatabaseConfig { useNestedTransactions = true }) } I use ktor-server-test-host, Test Containers and junit 5 to test the service. My test looks similar like below: #Testcontainers class SampleApplicationTest{ companion object { #Container val postgreSQLContainer = PostgreSQLContainer<Nothing>(DockerImageName.parse("postgres:13.4-alpine")).apply { withDatabaseName("database_test") } } #Test internal fun `should make request successfully`() { withTestApplication({ (environment.config as MapApplicationConfig).apply { put("ktor.database.url", postgreSQLContainer.jdbcUrl) put("ktor.database.user", postgreSQLContainer.username) put("ktor.database.password", postgreSQLContainer.password) } module(testing = true) }) { handleRequest(...) } } } I observed an issue that if I ran multiple test classes together, some requests ended up using old Exposed db instance that was setup in a previous test class, causing the test case failed because the underlying database was already stopped. When I ran one test class at a time, all were running fine. Please refer to the log below for the error stack trace: 2022-10-01 08:00:36.102 [DefaultDispatcher-worker-5 #request#103] WARN Exposed - Transaction attempt #1 failed: java.sql.SQLTransientConnectionException: HikariPool-4 - Connection is not available, request timed out after 30001ms.. Statement(s): INSERT INTO cards (...) org.jetbrains.exposed.exceptions.ExposedSQLException: java.sql.SQLTransientConnectionException: HikariPool-4 - Connection is not available, request timed out after 30001ms. at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_core(Statement.kt:49) at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:143) at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:128) at org.jetbrains.exposed.sql.statements.Statement.execute(Statement.kt:28) at org.jetbrains.exposed.sql.QueriesKt.insert(Queries.kt:73) at com.example.application.services.CardService$createCard$row$1.invokeSuspend(CardService.kt:53) at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt$suspendedTransactionAsyncInternal$1.invokeSuspend(Suspended.kt:127) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Caused by: java.sql.SQLTransientConnectionException: HikariPool-4 - Connection is not available, request timed out after 30001ms. at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:695) at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:197) at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:162) at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:100) at org.jetbrains.exposed.sql.Database$Companion$connect$3.invoke(Database.kt:142) at org.jetbrains.exposed.sql.Database$Companion$connect$3.invoke(Database.kt:139) at org.jetbrains.exposed.sql.Database$Companion$doConnect$3.invoke(Database.kt:127) at org.jetbrains.exposed.sql.Database$Companion$doConnect$3.invoke(Database.kt:128) at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction$connectionLazy$1.invoke(ThreadLocalTransactionManager.kt:69) at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction$connectionLazy$1.invoke(ThreadLocalTransactionManager.kt:68) at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:81) at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction.getConnection(ThreadLocalTransactionManager.kt:75) at org.jetbrains.exposed.sql.Transaction.getConnection(Transaction.kt) at org.jetbrains.exposed.sql.statements.InsertStatement.prepared(InsertStatement.kt:157) at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_core(Statement.kt:47) ... 19 common frames omitted Caused by: org.postgresql.util.PSQLException: Connection to localhost:49544 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:303) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51) at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:223) at org.postgresql.Driver.makeConnection(Driver.java:465) at org.postgresql.Driver.connect(Driver.java:264) at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358) at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477) at com.zaxxer.hikari.pool.HikariPool.access$100(HikariPool.java:71) at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:725) at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:711) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: java.net.ConnectException: Connection refused at java.base/sun.nio.ch.Net.pollConnect(Native Method) at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:542) at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) I tried to add some cleanup code for Exposed's TransactionManager in my application module as following: fun Application.module(testing: Boolean = false) { // ... val db = Database.connect(pool, {}, DatabaseConfig { useNestedTransactions = true }) if (testing) { environment.monitor.subscribe(ApplicationStopped) { TransactionManager.closeAndUnregister(db) } } } However, the issue still happened, and I also observed additional error as following: 2022-10-01 08:00:36.109 [DefaultDispatcher-worker-5 #request#93] ERROR Application - Unexpected error java.lang.RuntimeException: database org.jetbrains.exposed.sql.Database#3bf4644c don't have any transaction manager at org.jetbrains.exposed.sql.transactions.TransactionApiKt.getTransactionManager(TransactionApi.kt:149) at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt.closeAsync(Suspended.kt:85) at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt.access$closeAsync(Suspended.kt:1) at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt$suspendedTransactionAsyncInternal$1.invokeSuspend(Suspended.kt:138) (Coroutine boundary) at org.mpierce.ktor.newrelic.KtorNewRelicKt$runPipelineInTransaction$2.invokeSuspend(KtorNewRelic.kt:178) at org.mpierce.ktor.newrelic.KtorNewRelicKt$setUpNewRelic$2.invokeSuspend(KtorNewRelic.kt:104) at io.ktor.routing.Routing.executeResult(Routing.kt:154) at io.ktor.routing.Routing$Feature$install$1.invokeSuspend(Routing.kt:107) at io.ktor.features.ContentNegotiation$Feature$install$1.invokeSuspend(ContentNegotiation.kt:145) at io.ktor.features.StatusPages$interceptCall$2.invokeSuspend(StatusPages.kt:102) at io.ktor.features.StatusPages.interceptCall(StatusPages.kt:101) at io.ktor.features.StatusPages$Feature$install$2.invokeSuspend(StatusPages.kt:142) at io.ktor.features.CallLogging$Feature$install$2.invokeSuspend(CallLogging.kt:188) at io.ktor.server.testing.TestApplicationEngine$callInterceptor$1.invokeSuspend(TestApplicationEngine.kt:296) at io.ktor.server.testing.TestApplicationEngine$2.invokeSuspend(TestApplicationEngine.kt:50) Caused by: java.lang.RuntimeException: database org.jetbrains.exposed.sql.Database#3bf4644c don't have any transaction manager at org.jetbrains.exposed.sql.transactions.TransactionApiKt.getTransactionManager(TransactionApi.kt:149) at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt.closeAsync(Suspended.kt:85) at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt.access$closeAsync(Suspended.kt:1) at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt$suspendedTransactionAsyncInternal$1.invokeSuspend(Suspended.kt:138) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Could someone show me what could be the issue here with my application code & test setup? Thanks and regards.
BizTalk receiving from RabbitMQ
I'm new to RabbitMQ but I have now installed onto a Windows server and have a couple of demo console apps (C#) that happily write to a read from a queue. The following code works to pull messages from a queue called "RabbitPoCQueue_2" on the local server: string queueName = "RabbitPoCQueue_2"; var factory = new ConnectionFactory(); bool keepGoing = true; factory.HostName = "127.0.0.1"; try { using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { const bool durable = false; channel.QueueDeclare(queueName, durable, false, false, null); System.Console.WriteLine(" [*] Waiting for messages."); while (keepGoing) { var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea.Body; var message = Encoding.UTF8.GetString(body); System.Console.WriteLine(" [x] Received {0}", message); }; channel.BasicConsume(queue: queueName, autoAck: true, consumer: consumer); channel.BasicGet(queue: queueName, autoAck: true); System.Console.WriteLine("Press Y to continue or any other key to exit"); keepGoing = System.Console.ReadKey().Key == ConsoleKey.Y; } } } I now need to configure a BizTalk (2016 FP3 CU5) receive location to do the same. I have ensured I've stopped the console receiver and that I have messages sat on the queue for BizTalk to collect. I followed the article https://social.technet.microsoft.com/wiki/contents/articles/7401.biztalk-server-and-rabbitmq.aspx Problem is, when I start the receive location, I get no errors but nothing is received. The config for the WCF receive location can be seen below: and here: and here's a pic from the RabbitMQ management console showing messages sat on the queue: When I look in the RabbitMQ log file, I see 2 rows on starting the receive location. I see 3 rows when starting the .Net console app (using RabbitMQ API), as shown below - first 2 rows are from BizTalk, last 3 from the console app: 2019-08-28 16:17:45.693 [info] <0.13361.2> connection <0.13361.2> ([::1]:16807 -> [::1]:5672): user 'guest' authenticated and granted access to vhost '/' ** Start of Receive location 2019-08-28 16:19:57.958 [info] <0.13452.2> accepting AMQP connection <0.13452.2> (127.0.0.1:17173 -> 127.0.0.1:5672) 2019-08-28 16:19:58.026 [info] <0.13452.2> connection <0.13452.2> (127.0.0.1:17173 -> 127.0.0.1:5672): user 'guest' authenticated and granted access to vhost '/' ** Receive from command line 2019-08-28 18:56:26.267 [info] <0.13452.2> closing AMQP connection <0.13452.2> (127.0.0.1:17173 -> 127.0.0.1:5672, vhost: '/', user: 'guest') 2019-08-28 18:56:39.815 [info] <0.17923.2> accepting AMQP connection <0.17923.2> (127.0.0.1:41103 -> 127.0.0.1:5672) Can anyone spot where I went wrong?
When publishing to invalid queue, ReturnCallback is called but why is ConfirmCallback called for the same message
I am testing the ConfirmCallback, ReturnCallback flows for a simple Publisher->Exchange->queue and listener model. I have set the publisherConfirms, publisherReturns, mandatory to true . I published a new message to an existing exchange with an invalid queue name. As expected, I received the callback to the ReturnCallback.returnedMessage method. However I received a callback to the ConfirmCallback.confirm method as well. As i understand since the queue name is invalid only the ReturnCallback.returnedMessage method should have received the callback. Why does ConfirmCallback.confirm method gets invoked? I have tested the scenario many times and I have received the same result. Please check the below code snippets and the log file for your understanding and let me know if something is wrong. rabbitTemplate.setMandatory(true); rabbitTemplate.setConfirmCallback(new ConfirmCallback() { #Override public void confirm(final CorrelationData correlationData, final boolean ack, final String cause) { System.out.println("confirmCallback received with correlationData, ack, cause" + correlationData+ cause + ack); if (null != confirmCallbackUser) { confirmCallbackUser.confirm(correlationData.getId(), ack, cause); } }); rabbitTemplate.setMandatory(true); rabbitTemplate.setReturnCallback(new RabbitTemplate.ReturnCallback() #Override public void returnedMessage(final Message message, final int replyCode, final String replyText, final String exchange, final String routingKey) { Message msg = new Message(message); try { System.out.println("returnCallBackUser received with message, replyCode, replyText, exchange, routingKey" + message + replyCode + replyText+ exchange + routingKey); returnCallBackUser.returnedMessage(msg, replyCode, replyText, exchange, routingKey); } catch (MessagingException e) { System.out.println("returnCallBackUser exception : " + e.getMessage()); e.printStackTrace(); } System.err.println(" Message Returned"); } Logs 40053 [https-openssl-nio-8443-exec-6] DEBUG c.s.n.f.s.messaging.MessImpl **- Control reached send()** 40056 [https-openssl-nio-8443-exec-6] DEBUG o.s.a.r.c.CachingConnectionFactory - Creating cached Rabbit Channel from PublisherCallbackChannelImpl: AMQChannel(amqp://guest#127.0.0.1:5672/,2) 40056 [https-openssl-nio-8443-exec-6] DEBUG o.s.a.r.s.PublisherCallbackChannelImpl - Added listener org.springframework.amqp.rabbit.core.RabbitTemplate#7c8f1db1 40057 [https-openssl-nio-8443-exec-6] DEBUG o.s.amqp.rabbit.core.RabbitTemplate - Added pubsub channel: Cached Rabbit Channel: PublisherCallbackChannelImpl: AMQChannel(amqp://guest#127.0.0.1:5672/,2), conn: Proxy#6bc6056e Shared Rabbit Connection: SimpleConnection#69225b5 [delegate=amqp://guest#127.0.0.1:5672/, localPort= 60962] to map, size now 1 40057 [https-openssl-nio-8443-exec-6] DEBUG o.s.amqp.rabbit.core.RabbitTemplate **- Executing callback on RabbitMQ Channel: Cached Rabbit Channel:** PublisherCallbackChannelImpl: AMQChannel(amqp://guest#127.0.0.1:5672/,2), conn: Proxy#6bc6056e Shared Rabbit Connection: SimpleConnection#69225b5 [delegate=amqp://guest#127.0.0.1:5672/, localPort= 60962] 40061 [https-openssl-nio-8443-exec-6] DEBUG o.s.amqp.rabbit.core.RabbitTemplate **- Publishing message on exchange [ControlExchange], routingKey = [invalidQueue]** 40064 [https-openssl-nio-8443-exec-6] DEBUG c.s.n.f.s.messaging.MessImpl - **Control moving out of send()** ***returnCallBackUser received with message,*** replyCode, replyText, exchange, routingKey(Body:'[B#294b5bb4(byte[91])' MessageProperties [headers={IDENTITY=TOMCAT_CONTROL}, timestamp=null, messageId=null, userId=null, receivedUserId=null, appId=null, clusterId=null, type=null, correlationId=[80, 114, 111, 100, 117, 99, 101, 114], correlationIdString=null, replyTo=ControlExchange/ComAckQueue, contentType=application/octet-stream, contentEncoding=null, contentLength=0, deliveryMode=null, receivedDeliveryMode=PERSISTENT, expiration=null, priority=0, redelivered=null, receivedExchange=null, receivedRoutingKey=null, receivedDelay=null, deliveryTag=0, messageCount=null, consumerTag=null, consumerQueue=null])312NO_ROUTEControlExchangeinvalidQueue 40066 [AMQP Connection 127.0.0.1:5672] INFO c.s.n.f.s.m.CallBackRecReplyInterfaceTemplate - Message {"Test":"abcd","Role":"abcd","Id":"1111","request":"Accepted","De":"invalidQueue"} replyCode-> 312breplyText-> NO_ROUTE exchange-> Exchange routingKey-> invalidQueue **Message Returned** 40066 [AMQP Connection 127.0.0.1:5672] DEBUG o.s.a.r.s.PublisherCallbackChannelImpl - **PublisherCallbackChannelImpl: AMQChannel(amqp://guest#127.0.0.1:5672/,2) PC:Ack:1:false** 40067 [AMQP Connection 127.0.0.1:5672] DEBUG o.s.a.r.s.PublisherCallbackChannelImpl - **Sending confirm PendingConfirm [correlationData=CorrelationData [id=corrlDat]] confirmCallback received with correlationData, ack, causeCorrelationData [id=corrlDat]nulltrue** 40067 [AMQP Connection 127.0.0.1:5672] INFO c.s.n.f.s.m.CallbackConfirmImplTempl - **ACK->truecause->nullcorr id corrlDat 40067 [AMQP Connection 127.0.0.1:5672] INFO c.s.n.f.s.messaging.MessagingImpl - ACK->truecause->nullcorr id corrlDat**
Publisher Confirms calls when broker finished handle it. In case of wrong queue, broker sends confirm when it will verify that message won't route. See documentation in section "When will messages be confirmed".
How to get authenticated to Redis Cloud Memcached using Spymemcached?
I am trying to connect to Redis Cloud Memcached but get an error (below). I have checked that the username, password, host, and port are correct in the apps.redislabs.com interface. I able to connect if I disable SASL and connect unauthenticated. How can I diagnose this? (Using spymemcached 2.11.6.) import net.spy.memcached.auth.*; import net.spy.memcached.*; ... List<InetSocketAddress> addresses = Collections.singletonList(addr); AuthDescriptor ad = new AuthDescriptor(new String[] { "CRAM-MD5", "PLAIN" }, new PlainCallbackHandler(user, password)); MemcachedClient mc = new MemcachedClient(new ConnectionFactoryBuilder() .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setAuthDescriptor(ad).build(), AddrUtil.getAddresses(host + ":" + port)); The stacktrace: net.spy.memcached.MemcachedConnection: Added {QA sa=pub-memcache-14154.us-central1-1-1.gce.garantiadata.com/104.197.191.74:14514, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl: Discarding partially completed op: SASL auth operation net.spy.memcached.MemcachedConnection: Reconnecting due to exception on {QA sa=pub-memcache-14154.us-central1-1-1.gce.garantiadata.com/104.197.191.74:14514, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=1} java.io.IOException: An existing connection was forcibly closed by the remote host at sun.nio.ch.SocketDispatcher.read0(Native Method) at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) at sun.nio.ch.IOUtil.read(IOUtil.java:192) at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:820) at net.spy.memcached.MemcachedConnection.handleReadsAndWrites(MemcachedConnection.java:720) at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:683) at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:436) at net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:1446) net.spy.memcached.MemcachedConnection: Closing, and reopening {QA sa=pub-memcache-14154.us-central1-1-1.gce.garantiadata.com/104.197.191.74:14514, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=1}, attempt 0. net.spy.memcached.MemcachedConnection: Could not redistribute to another node, retrying primary node for foo.
Lose the "CRAM-MD5" in your AuthDescriptior declaration. The following works in my tests: (user, pass, and url removed) AuthDescriptor ad = new AuthDescriptor(new String[] {"PLAIN"}, new PlainCallbackHandler(user, pass)); MemcachedClient mc = null; try { mc = new MemcachedClient( new ConnectionFactoryBuilder() .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setAuthDescriptor(ad).build(), AddrUtil.getAddresses(host + ":" + port )); } catch (IOException e) { // handle exception } mc.set("foo", 0, "bar"); String value = (String) mc.get("foo"); System.out.println(value);
Socket.io-objc 400 (Handshake Error) Remote Server vs. localhost
When I connect to Socket.io on the server I get a 400 error, but I don't see any errors connecting to localhost. (same code and connecting via socket.io-objc) I'm using Azure to host the node.js project. (I also have websockets on in the azure config if that makes a difference) ERROR: handshake failed ... The request timed out. onError() Error Domain=SocketIOError Code=-6 "The operation couldn’t be completed. (SocketIOError error -6.)" UserInfo=0x1874cc00 {NSUnderlyingError=0x1870cad0 "The request timed out."} Server Code (On Azure) var fs = require('fs'); var app = require('express')(), server = require('http').createServer(app), redis = require("redis"), Primus = require('primus'), kue = require("kue"); var haversine = require('haversine') var finish = require("finish"); var client = redis.createClient(12276, "redis url"); client.auth('password'); var io = require('socket.io').listen(server); io.sockets.on('connection', function (socket) { socket.emit('join', { status: 'connected' }); }); var port = process.env.port || 1337; server.listen(port); SOCKET.IO-OBJC CODE - (void) reconnect { [socketIO disconnectForced]; socketIO = [[SocketIO alloc] initWithDelegate:self]; socketIO.useSecure = NO; [socketIO connectToHost:#"siteurl" onPort:80]; }