aciidgh / SwiftMQTT

MQTT Client in pure swift ❤️
MIT License
270 stars 71 forks source link

Subscribe socket error at 2 message #42

Open k4reash opened 5 years ago

k4reash commented 5 years ago

Hi, I can't receive more than 1 message without disconnection (Socket error)

What is the correct way to suscribe to a topic?

This is my code:

https://pastebin.com/ad1D8P4w

k4reash commented 5 years ago

Error in console: nw_socket_handle_socket_event [C1:1] Socket SO_ERROR [54: Connection reset by peer]

kervich commented 5 years ago

I suspect this is a duplicate of #39 - @alexkite03, what version of Xcode/Swift toolchain are using? One of the "effects" of #39 is that msgID is not read (or parsed right for that matter) from the subscribe ack and the socket hangs open waiting for the ack with expected msgId to be received, however server drops the socket after a while, since the ack has been sent and delivered, but never acted upon.

jamesbebbington commented 5 years ago

Hey @kervich, I'm seeing the same issue on Xcode 11 Beta (11M336w) on macOS 10.15 Beta (19A471t).

cdf1982 commented 3 years ago

Hello, I'm also experiencing the same issue ("[connection] nw_socket_handle_socket_event [C1:1] Socket SO_ERROR [54: Connection reset by peer]") where the connection is closed after successfully receiving the first message; if I don't send messages, pings are regularly received without never closing the connection. Anyone found a workaround?

EDIT: Someone did!, the commit 0b3256f7b4575dc5b263c415d8a387c8ae9812b4 works like a charm.