WebSocket: onMessage() only triggered at the end when server is closing connection - javascript

I have a weird error that I can not solve.
My implementation WebSocket works perfectly. The browser connects to the server, exchange their keys and the connection is fully established! The server starts sending messages to clients (visible in the network traffic).
But on my PC, all browsers (Chrome, Firefox, portable or not), the "onMessage ()" is correctly interpreted ... but only at the end when I turn off the server! In other words, if I put an alert () to each onMessage (), during exchange, I did absolutely nothing. But once I cut the server, I receive all alerts at once!
Yet on my MacBook everything works perfectly.
This ironic is it that behavior that affects all of my browsers on my PC. I run under Windows 7.
Thank you in advance ;)

I've finally found the issue !
If you have some troubles with Websockets, just disable the SSDP discover service on Windows.
net stop SSDPSRV

I ran into a similar issue recently. web server runs a separate SSDP discovery process to find uPnP devices on the network. When I had SSDP enabled, my websocket connection was always closed. Disabling SSDP solved it. But I haven't had a chance to investigate why.

Related

net::ERR_NETWORK_CHANGED on Chrome on Https socket connection

I'm running a Server-sent Event (SSE) server over Ingress/Kubernetes/GoogleCloud and it works like a charm. I can run SSE clients over the web and they connect perfectly, start receiving events with no problem.
But there's one ugly bug I can't get it work right, on Chrome browsers after some time I get net::ERR_NETWORK_CHANGED error. No matter how many times I run it, I always get it after a few seconds/minutes.
If I run the same client over Firefox, nothing wrongs happens. If I run it using cURL over terminal, nothing wrong happens.
If I decide to run if over Chrome without HTTPS, it works! I'm only getting it when running it through HTTPS and on a Chrome browser.
Has anyone encountered this before? Seems like a ugly bug for me.
I'm having the same problem but it's sporadic.
From the Chromium project source code: OnNetworkChanged will be called when a change occurs to the host computer's hardware or software that affects the route network packets take to any network server. Some examples:
A network connection becoming available or going away. For example
plugging or unplugging an Ethernet cable, WiFi or cellular modem
connecting or disconnecting from a network, or a VPN tunnel being
established or taken down.
An active network connection's IP address changes.
A change to the local IP routing tables.
Hope it helps
For me using a mac system and chrome for a daily basis, I encounter this problem now and then and finally found it might be helpful to solve this problem by just turning off the virtual machines or dock containers whichever can adjust your network configuration.
Maybe not fit for your case but it could be a hint. I saw a lot of people having this kind of issue with chrome.

Is Chrome microphone supposed to be not working if there is no Internet Connection?

I'm using a JS plug-in called Annyang, a Speech Recognition tool and of course it requires a working mic. Everything works just fine with normal Internet connection, but when I disable my Internet Connection, the plug in won't work at any level. (and I did check the plug-in's JS file and found nothing that needs any Internet Connection to be functioned.
Is Chrome microphone supposed to be not working if there is no Internet Connection ? Or something is wrong with the plug-in..?
Thanks a lot for reading this question. Have a good day :)
It's not the microphone that needs internet connection,
it's google's implementation of speech-recognition API, which sends the recorded data to their server to get the computed STT.
Nothing you can do on your side, not an Annyang bug either.

Cordova hybrid app- HTTP requests are very slow

I am building a hybrid app, with AngularJS, Cordova, Restangular ond client side and Python with wsgiref.simple_server on server side. I am not doing anything special, this is very simply requests like this:
Restangular.one('/devices').get().then(function (response) {
viewModel.devices = Restangular.stripRestangular(response.devices);
});
I set baseUrl for Restangular:
.config(function(RestangularProvider){
RestangularProvider.setBaseUrl('http://192.168.54.102:8000/');
})
And when I use it on local computer with Chrome browser, everything is fast, works normal. But when I use it on Android on Phonegap developer app on device or install app on device with Android, it works crazy slow. It looks like it is send to server with big delay, cause it takes some time as I see debug server log on server side. It occurs also when python application with server is not in debug mode, for example when I start it normally after install on local computer. As I see some people has this problem, does anybody found a solution or a reason, which causes very slow HTTP requests in hybrid application? Thank you in advance for every answer.
Since you are a hybrid developer, I am sure you are familiar with the Chrome DevTools. For me on a Mac, hit cmd + option + i, or go to View -> Developer -> Developer Tools.
The really great thing about Chrome in recent history is it now works with Android WebViews too. Hybrid developers haven't always had this convenience, and had to debug essentially handcuffed using tools like Weinre.
Now we can use the DevTools directly in the Chrome browser while your Android device is connected by ADB from a new tab calling chrome://inspect
Here is some more detailed information on how to do this if you get stuck.
From here open up the network panel and see how long your requests are taking. If they are showing a significantly longer amount of time to load here, the issue has nothing to with Angular, Cordova, Restangular or probably even Hybrid architecture at all. I would check your network and performance elsewhere on the device.
If this is definitely not the issue, I would use the Timeline tab in the DevTools to see what is taking so long between your browser receiving the information and your device displaying it. If there is any significantly longer process taking place in between, you will see it here.

Websockets message loss

When using websockets I noticed some message loss. I am trying to communicate between mobile safari (client) and c#(server). I am using superWebSocket (opensource) as a server, so it might be a server bug...
But the messages are only dropped when the connection is congested (When I send alot of messages). This "reaks" of UDP to me, but I remember reading somewhere that web-sockets are TCP.
Is there any occasion where I might issue a "send" command in javascript, and the receiving side does not get the message?
I've been using WebSockets extensively in with high traffic applications and in situations where a single lost message (in either direction) is fatal. I've never seen any messages lost, ever. However, I do recall seeing a post or question somewhere about the same issue and that person was also using superWebSocket for the server. So my strong suspicion is that there is a bug in superWebSocket.
Do you see the same problem if you use a non-mobile browser? It's possible the iOS brower (I assume that's what you mean by mobile Safari) has a WebSocket bug. I've not extensively tested that browser with WebSockets. I have extensively tested Chrome, Firefox (with WebSocket enabled), and Opera (with WebSocket enabled) on Linux and Windows and Safari on Windows.
There is no occasion where a send in Javascript is allowed to not reach the server except if the whole connection fails. If that is happening then there is a bug somewhere.

Socket.io not handling JSON in IE and Firefox

Using the example chat application here, I've written a simple Socket.IO application served over Node.Js which polls a JSON file using a fileRead from the server side and broadcasts the parsed JSON values over to the client side, where I've displaying them.
This works really well in Chrome, Safari and Opera (all those who support WebSockets).
However in Firefox, it fails until I start the Firebug console. That's when the handshake happens and the data is displayed.
In IE, it just doesn't work.
When I deploy the same code with SSL, it works everywhere. Any ideas on what I'm doing wrong here? EDIT: Now it doesn't seem to work on SSL too :(
However in Firefox, it fails until I
start the Firebug console. That's when
the handshake happens and the data is
displayed.
Sounds like this might be a console.log() problem. Firefox will hang if you call console.log() without actually having a console open.

Categories

Resources