How can I maintain a consistent WebSocket connection over cellular networks?

Mobile / Cellular networks are known to cause problems with persistent connections and interfere with Internet traffic. Due to this some mobile data networks will not allow a WebSocket to connect over WS and port 80. Because of this connections should be made over WSS and port 443.
How does this affect your application?
If you are using the Pusher JavaScript library it will initially try to connect over WS and port 80. When this fails it will automatically try WSS and port 443 and successfully connect.
If you are using another client library you may need to configure the client to connect over WSS.
pusher-js (JavaScript)
The client will automatically connect. However, you can configure the client to connect over WSS by default:
var pusher = new Pusher( 'app_key', { encrypted: true } );

libPusher (iOS)

By default the connection to Channels will be made over TLS. It is possible to change by setting encrypted to NO.

self.client = [PTPusher pusherWithKey:@"APP_KEY" encrypted:YES];
Was this article helpful?
0 out of 0 found this helpful
Haven't found what you were looking for?
Submit a ticket