socket.io errors when client connects - javascript

I have socket.io running successfully on my node.js installation.
info - socket.io started
The console shows it running ok, but as soon as the client (browser) connects:
socket = io.connect('<my host>:8000');
The console is kicking out an error:
crypto.js:123
return new Hash(hash);
^
TypeError: undefined is not a function
at Object.createHash (crypto.js:123:10)
at WebSocket.onSocketConnect (/node_modules/socket.io/lib/transports/websocket/hybi-16.js:120:23)
at WebSocket.handleRequest (/node_modules/socket.io/lib/transport.js:71:10)
at WebSocket.Transport (/node_modules/socket.io/lib/transport.js:31:8)
at new WebSocket (/node_modules/socket.io/lib/transports/websocket/hybi-16.js:59:13)
at new WebSocket (/node_modules/socket.io/lib/transports/websocket.js:31:17)
at Manager.handleClient (/node_modules/socket.io/lib/manager.js:661:19)
at Manager.handleUpgrade (/node_modules/socket.io/lib/manager.js:618:8)
at Server.<anonymous> (/node_modules/socket.io/lib/manager.js:123:10)
at Server.emit (events.js:88:20)
can anyone understand what this might mean?
My code has been working fine on my local machine, its only when moving it to my production server does this error happen.

It turns out it's because Node was installed with the option --without-ssl. This means it doesnt install any of the crypto stuff, which was needed by socket.it. I installed openssl, reinstalled Node, and this fixed it :)

Related

Discord.JS TLS errors

I have been working on a bot for some time now. Since I updated it to v15.5.0, after a while it works fine, does exactly what I want but then crashes, giving the following error. This seems to be a TLS issue.
Error: Client network socket disconnected before secure TLS connection was established
at connResetException (node:internal/errors:631:14)
at TLSSocket.onConnectEnd (node:_tls_wrap:1565:19)
at TLSSocket.emit (node:events:388:22)
at endReadableNT (node:internal/streams/readable:1305:12)
at processTicksAndRejections (node:internal/process/task_queues:80:21)
The source code for the bot is here
Will I have to downgrade? If so, to what version of node?
I'm using this on a Windows 10 64bit computer with no proxy settings whatsoever.
This is not related to Node.js v15, but it seems like it is an issue on your end (with your connection, or your computer). this question may help you to resolve your issue.

React Native -- cannot start because HTTP server already being used by another WebSocket server

I'm running npx react-native start/npx react-native run-android, and everything builds fine; however, the app cannot start a server properly. This is the error I'm getting:
Error: The HTTP/S server is already being used by another WebSocket server
at new WebSocketServer (.../node_modules/ws/lib/websocket-server.js:83:15)
at Object.attachToServer (.../node_modules/react-native/node_modules/#react-native-community/cli/build/commands/server/messageSocket.js:93:15)
at Object.runServer [as func] (.../node_modules/react-native/node_modules/#react-native-community/cli/build/commands/server/runServer.js:127:37)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Command.handleAction (.../#react-native-community/cli/build/index.js:164:9)
I've tried killing all react-native related processes, and even if I reboot the system, this error still persists. Any ideas on what might be causing this?
It looks to me like your processTicksAndRejections() method is trying to set up its own WebSocketServer instance to do its work, rather than using one that's already set up. Your error message means that you
already have an http/s server going
already have a websocket server set up on it
you're trying to set up another websocket server on that existing http/s server.
If you were trying to run two server processes on the same port, a different error message would show up.
I ended up solving this problem by removing the dependency #react-native-community/cli-platform-android altogether, but I'm not completely satisfied with the solution because I have to run npx react-native start and npx react-native run-android separately.

Node.js sails.js pm2 ec2 instance error due to memory

I am currently running a basic website on an amazon EC2 t1.micro instance.
The application is built using sails.js / node.js and is booted up using pm2.
After a while I get the following message in the errors log file and the server crashes:
FATAL ERROR: Committing semi space failed. Allocation failed - process out of memory
Could somebody help me with this issue?
Have I misconfigured something?
I am running:
Node version 5.9.0
NPM 3.7.3

How to run johnny-five on Ubuntu 15.04?

$ node hello.js
1436894483255 Device(s) /dev/ttyUSB0
1436894483279 Connected /dev/ttyUSB0
1436894493287 Device or Firmware Error A timeout occurred while connecting to the Board.
Please check that you've properly flashed the board with the correct firmware.
See: https://github.com/rwaldron/johnny-five/wiki/Getting-Started#trouble-shooting
events.js:87
throw Error('Uncaught, unspecified "error" event.');
^
Error: Uncaught, unspecified "error" event.
at Error (native)
at Board.emit (events.js:87:13)
at Board.log (/usr/lib/node_modules/johnny-five/lib/board.js:623:8)
at Board.(anonymous function) [as error] (/usr/lib/node_modules/johnny-five/lib/board.js:634:14)
at Board.<anonymous> (/usr/lib/node_modules/johnny-five/lib/board.js:407:12)
at Timer.listOnTimeout (timers.js:119:15)
I have installed node and johnny-five on Ubuntu and connected Arduino Nano. But it's throwing the above error.
before you run your node app, try to open arduino:
$ arduino
go to to file > Examples > Firmata, and choose StandardFirmata
once it opens upload it to your arduino.
when done, you should be able to run your node app without any problems
The arduino IDE might be holding the connection to the board. Try closing it.

Meteor on windows - Server crashes on code push

I installed Meteor for windows from here :
http://win.meteor.com
The server crashes almost every time I try to make live code push.
I would then have to end the mongod.exe process and run 'meteor reset' and 'meteor' to start it up back again.
Here are the logs:
=> Meteor server restarted
events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: This socket is closed.
at Socket._write (net.js:519:19)
at Socket.write (net.js:511:15)
at Socket.HttpProxy.proxyWebSocketRequest.reverseProxy.incoming.socket.on.listeners.onOutgoing (C:\Program Files\Meteor\lib\node_modules\http-proxy\lib\node-http-proxy\http-proxy.js:515:35)
at Socket.EventEmitter.emit (events.js:96:17)
at TCP.onread (net.js:397:14)
Anyone on the same boat? I read from here https://github.com/meteor/meteor/issues/513 that this has been an open issue for over 6 months.
Someone's got any workaround? Help appreciated.
The EADDRINUSE issue was fixed in 0.6.3.1-rev4, but please update to version 0.6.4 as this problem seems to have resolved the other issue by the update to the http-proxy package.
For MSI downloads see https://github.com/sdarnell/meteor/wiki/Windows
Should also appear on http://win.meteor.com soon
This is a known issue with windows for meteor : https://github.com/sdarnell/meteor/issues/7. The one on meteor's github repo might also be related. I have it too! Hopefully they sort it out soon!. Just ctrl+c to stop your server before you edit code and get it back up after you're done.
Even if you start it after this sometimes you could also get an ADDRINUSE error, which is quite frustrating.

Categories

Resources