Tuesday, 08 September 2020
  5 Replies
  1.3K Visits
  Subscribe
Hi folks,

I'm still exploring the MQTT protocol (testing v 3.1.1) with sgcWebSockets, I have succesfully established connections with a private cloud server ( from Delphi & Lazarus for Linux ), I can send and receive messages, but now I'm facing an issue sending a large text when publishing a message, let me describe the flow here:

1. There is the cloud server where all messages are routed.
2. There are local database servers on differents locations which will subscribe to a topic and when required they will gather some info from their database and send the data as a payload publishing a message to the cloud server.
3. There are mobile devices subscribed to a topic where the data sent in the previous step will be received and processed

So now to the issue:
If the data ( a json text ) is small lets say a few kb, then everything works as expected, but if the json is bigger ( 4 Mb in the test scenario ) I'm having disconnections from the cloud server testing on locations with very low bandwidth ( I can see on server's log messages like "... stopped due to keepalive expired ..." ) so it seems like a keepalive timeout must be set from my side, so what would that be ?

TsgcWebSocketClient.ConnectTimeout
TsgcWebSocketClient.HeartBeat
TsgcWSPClient_MQTT.HeartBeat
Any other ?

I'll try to decrease the size of the json, but inevitably there will be times when the text will be large enough to send, unfortunatelly the cloud server I'm using doesn' have support for Deflate frame extension, perhaps I must create a compressed zip stream on my side and publish that stream?, any pointers here will be very welcomed

Additionally, those local servers could receive more than one request at the time, so What will be the best practice here? Create another thread with his own TsgcWebSocketClient + TsgcWSPClient_MQTT pair for each request to publish the message with the json data ?

Thank you all in advance