Websocket send not working from phone network - ruby

I have a game based on websockets for real-time. With WIFI everything is working as expected. But over phone network, the connection is opened but messages aren't received on the server. While the server pings are received at the client. I am using websocket implementation on heroku using ruby/sinatra for the server and my client is an android app using a websocket library.
This behavior only happens from a 3G phone network and not WIFI.
I have read about websockets not working from phone network because of proxy servers used by phone network providers, then how come I receive the pings from the server? Please help.

I resolved this issue by passing it over SSL. I used wss:// instead of ws:// and it worked fine even over phone network.

Related

WeChat WebSocket communication works only on an emulator

I'm trying to do send some messages (MQTT) using WeChat and WebSockets. I'm following steps described on https://segmentfault.com/a/1190000040627614/en . It's working perfectly in an emulator but not on a real device. It's not able to connect. Are there any settings in WeChat blocking such connections?

Can we host a host websocket server in cloud as proxy/relay server to redirect websocket traffic from local network

[This post has been updated with a possible approach, which is added to the bottom]
I am trying to create a web socket connection between two devices((A). chrome in different computer and (B) a raspberry pi) in different networks. Thus, i can send video data over websockets. However, I cannot port forward the network of my router to expose my local IP to the network, thus, I can't send the data right away.
Figure below explains the architechture.
Thus ,I am trying to implement a logic so that Device A websockets the public ws of the cloud while, the cloud actually gets the data from Device B.So Device A websockets device B indirectly.
Device A<==>Cloud Server<==>Device B
The cloud could be something like a proxy or a relay websocket server.
The video feed needs to be sent in real time,
Please suggest how can i proceed with it.
Additional note, i have acquired an instance of digitalocean as VPS, following the blog Accessing home services from anywhere, without port forwarding! but not sure how to proceed.
Update(11th Nov,2019):
I am planning to use a websocket server on DigitalOcean instance(droplet),which would be listening to my local IP/port of my raspberry pi.And this VPS would act as a websocket server,which would redirect the traffic.
However, I am unsure how to use the same.And need your kind suggestions.

Websockets Disconnected when intermittant network drop or Network swtiched

We are using tomcat websocket implementation in our web application. Messages are pushed from server to client through websockets. Web socket messages are not pushed when intermittant connection drop or network is switch over but still web application is connected.
Let say for example i am connected to LAN and logged in app, now i connecting through wifi after wifi successfully connected i am disconnecting LAN with in fraction of second network is switched from LAN to wifi But after this messages are not pushed from server to client through websockets.
After network switch if i check the state of the websocket(readyState) which says 1 which means websocket connection is open but actually its not.
Can anyone faced this issue earlier and provide your suggestions.
Thanks
You must create a connection drop detection mechanism. The WebSocket protocol has ping/pong frames, but I don't know if Tomcat has that functionality. In some Webscoket frameworks you can define a timeout interval, and the server will ping the client regularly, if the client miss some pongs is disconnected.
If that functionality is not provided by Tomcat, you can still create your own. Just define a special type of message and repeat it to the server from the client. If you do not get any of those messages for a while, disconnect.

socket.io not connecting to mobile browser

I wanna create a connection between my mobile Safari and nodejs + socket.io on my Macbook.
When i call localhost:8080 from my laptop, everything works fine. The console says that the client is connected and my little website is displayed.
When i call it over my mobile browser with 10.0.1.5:8080, the website is displayed as well, but my socket.io don't identify the mobile browser (iPhone) as client and nothing happens on the console board.
Does anybody where the problem is?
I found this post on SO, probably can help you out. why does my nodejs socket.io app not work on ios6
Localhost is local to the machine. You're IP should use a ip address
or domain name:
something like: io.connect('192.168.1.110'); or
io.connect('test.myapp.com');
WebSockets do not work over cellular network as they are not forwarded by the http proxy.
A possible workaround it to set the WebSocket server port to 443 (https) which forwards everything (as https is encrypted the proxy has to forward it in order to support https).
To see a real world example which solves this problem this way checkout nearby.
Remember this requires using two http servers:
Serving you mobile application (on port 80)
Serving the web sockets on (port 443)
Else you always have to use the specific ports in your urls which is mostly not preferred in production.

Send Push Notifications Through Proxy (APNs and GCM)

I have built both ios and android apps which will receive push notifications. The problems are NOT from device side but from server side.
Because our company's internal server must connect to external network through Proxy, when users send notifications to mobile devices, the server which handles sending notification request must send request to proxy server then proxy server forwards request to APNs and GCM.
I have no idea about how to send push notification requests through proxy. I have studies in this case for several days, but no solutions have been found.
I saw some guys said APNs does not allow connections coming from Proxy Server. Only direct connection is accepted. Is that true? Is there any official docs mentioned it?
Is there anyone able to help me?
I wanna know how to send push notification through proxy for ios and android.
If you are using Java.You can use javaApns enter link description here for ios. I my self have problem right now to get GCM to send through proxy on my Server local it works. If you can you can configure the application server to send through proxy.

Resources