nodejs websocket initial connection timeout - node.js

I have a node client that tries to connect to a Websocket server that is behind an ELB.
Sometimes, the initial connection hangs and does not return, and i was wondering if there's a timeout options in websockets/ws module.
I saw that it's using the native https/http node lib and that lib has a setTimeout method - but it's not being used.
I patched my installed module to use that method and it worked.
Is there another option I'm not aware of? Should I submit a PR?
Thanks!

in case anyone has the same issue, i added this feature in 3.0.1 https://github.com/websockets/ws/commit/b32016995e9620ed6d5826464b2c3ee931e2240a

Related

Reusing RabbitMQ connection per expressjs api request

We are trying to use rabbitmq using this library called amqplib (not node-amqplib). Now all docs and examples I read say the connections should be long term. So my original thought of as soo nas someone makes a request to our web server (express), it will open a connection thus open a channel thus a queue so on and so forth. But that means per request we will be constantly opening and closing which is said ia not how you should ot it.
So, with that said, if you have an express server or some nodejs arch which involves pusblishing data per http request, is there some standard? do i make the connection object global and then any functions i need to use it, i pass it in/call it? is there som,e better way to get that connection instance per request without re-creating it?
Thanks in advance!

Angular Universal with GRPC

Im having issues with setting up GRPC inside Angular Universal App.
Basically, it throws an error:
ERROR Error: This environment's XHR implementation cannot support binary transfer.
This error is breaking the application on production (hosting it on ubuntu and nginx), but, in local envioroment it works.
If I switch Angular to not use SSR, then it works fine.
My assumption is that in the Node Express server I need to add support for GRPC, but im not sure how to achieve that.
Did someone had the same problem?
Thanks!
If no grpc library is defined, adding improbable-eng should solve the issue. The mentioned error message occurs when the transport protocol is not NodeHttpTransport.

Socket.io connection breaks on "socket.emit()" in some cases

I am building an app with node.js as server and vue.js in frontend with this package https://github.com/MetinSeylan/Vue-Socket.io
I am sending a lot of data from the server to the client (inital on connection)
Node.js loads the data from mongodb.
So in some cases, when I do a
socket.emit()
the connection breaks up (with no error) and does instantly a reconnect. And this in an infinit loop.
I found out, that the problem was once caused by german "Umlauts", for example "ä, ö, ü", etc. I fixed this issue by doing this encodeURIComponent(JSON.stringify(myDataToSend))) and in the frontend decode it like this: JSON.parse(decodeURIComponent(payload))
So now this doesnt help anymore and I cant figure out why. And there is no kind of error log or something where I can start debugging, it just breaks up and reconnects forever.
Can this happen because my Object I want to send to the client is too big?
I tried sending my data in smaller packages one after another and this did not break. I hoped I would find the problem like this.
Any advice for debugging or ideas for packing my data is appreciated.
I found the issue wich caused my problem.
Note: I have still no idea, why the socket connection crashed in my case, but I used the package in the "wrong way".
I did:
Vue.use(VueSocketio, 'http://socketserver.com:1923', store);
but the kind of better way ist
Vue.use(VueSocketio, socketio('http://socketserver.com:1923'), store);
vue-socket.io uses a very old version of the socket-io.client when just using a string as connection and no actual socketio instance.
Maybe this helps someone else

Incredibly slow outbound HTTPS requests

I am using Node 0.12.2 with Express 4.13.3 as the frontend for a RESTful layer. Calling the API's from cURL/Postman takes ~9ms. However, using Request 2.60.0 to make the call from Node, it takes ~60ms. These are HTTPS calls. Removing HTTPS and using just HTTP brings Node down to ~7ms. Both the curl/Postman calls and the Node.js calls are happening on the same machine in the same environment under no load. I cannot seem to find what's causing Node to be so much slower than everything else. Any help would be greatly appreciated.
Updating to Request 2.61.0 fixed the issue. Looks like there was an issue with their agent pool.

Meteor methods don't work on Modulus server

I had an app deployed on Meteor's servers and it worked as expected.
Now, I've moved the app to a NodeJS platform, called Modulus, using their CLI tool. (App hosted at http://crazygain.com)
For some reason, the method calls - Meteor.call or Meteor.apply - are not executed. Looking at the network indicator in Chrome Dev Tools I saw that the request is never sent.
I tried sending requests directly from the console, and got the same result.
e.g. when I execute the following
Meteor.call("foo",function(){console.log("callback");});
on the new Modulus server I simply get undefined
However, when I run it on the old Meteor server I get the "callback" log as expected.
I'm quite puzzled and unsure what can cause such behaviour.
UPDATE:
meteor.status() returns
Object {status: "connected", connected: true, retryCount: 0}
This might be because the web socket connection isn't established. Meteor calls & subscriptions depend on the DDP protocol which have a separate connection to the server.
Have a look at Meteor.status() to see if you are connected & if not investigate your connection's web socket/long polling connection.
It might just be a connection issue. Your meteor call works for me with the site you have provided.
Have you followed the Meteor deployment guide on Modulus' website? You need to convert the app using demeteorizer.

Resources