iOS - "Socket closed by remote peer" while connecting to RabbitMQ live server

624 views
Skip to first unread message

Rinkal Chahodiya

unread,
Jul 20, 2021, 12:52:12 AM7/20/21
to rabbitmq-users
Hello, 
I am facing this error when a message should be received from server after sending from client app. It works very well on localhost with no issue. Here is the complete error message I am getting.
 
Received connection: <RMQConnection: 0x6000022e2eb0> disconnectedWithError: Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer}

My swift code look like this: 

let uri = "ampqs://[username]:[password]@[broker-id].mq.[region].amazon.aws.com:5671/".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! 

let conn = RMQConnection(uri: uri, delegate: RMQConnectionDelegateLogger()) conn.start() 

let ch = conn.createChannel() let q = ch.queue(UUID().uuidString, options: .durable)
let exc = ch.direct("my-exchange-name-here") 
q.bind(exc, routingKey: "my-routing-key") 

print("Waiting for messages \(rountingKey)") 

q.subscribe({(_ message: RMQMessage) -> Void in 
print("Message received")
 })

Let me admit that, when I set this subscriber I do not get any error message regarding connection or anything. so I think it is connecting to the server without any issue. 

But, when I send a message from the iOS app, the backend publish it and so the iOS app should receive it back. Exactly at this time, it gives me the above error!.

I am stuck with this since 3 days. Someone please help me.

Any help would be appreciated.

Thanks.

Rinkal Chahodiya

unread,
Jul 21, 2021, 5:10:12 AM7/21/21
to rabbitmq-users
Reply all
Reply to author
Forward
0 new messages