Get error when i try to test Multi-Room Chat Application sample code - node.js

i found this sample code from github as chat-nodejs named and i want to test it how is it work, after installing socket.io and expressjs and running server and click to connect to server i get this error on firebug:
GET https://apis.google.com/_/scs/apps-static/_/js/k=...TcCOZ5yY8jtGvNKVwrKHFFcvb9eCe_w/cb=gapi.loaded_1
GET http://localhost/socket.io/?EIO=3&transport=polling&t=LbtPp7S
"NetworkError:404 Not Found -
http://localhost/socket.io/?EIO=3&transport=polling&t=LbtPp7S"?EIO=3&...LbtPp7S
Cross-Origin Request Blocked:
The Same Origin Policy disallows reading the remote resource at
http://localhost/socket.io/?EIO=3&transport=polling&t=LbtPp7S.
(Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

You're getting a NetworkError:404 Not Found because the serverAddress in Line 15 of chat.io.js doesn't have the server port 8080 in it. Add port number to it.
serverAddress = 'http://localhost:8080',
Additionally, socket.io might not work well if the client and server installation of it, are of different version.
index.html doesn't use a local one. The recent version of socket.io dint work for this repo. I had to install 0.9.13 on the server side for it to work.

Related

Cannot read property 'NODE_ENV' of undefined in nodejs on https SSL

I have install the ssl certificate in my angular and nodejs project. but after installing the certificate i am unable to login into my application. My main index.js file is running perfectly, but when i am tried to login from my application, it showingn me 500 (Internal Server Error) with a message (Cannot read property 'NODE_ENV' of undefined). I am showing you the localhost but the same problem is coming on production.Please help me out here, how can i fix it.
My error image of application
My nodejs console working picture
It's not HTTPS SSL problem.
Seems that the problem is on the file which defines a handler for POST /login, attach this file for more details.

Node.js socket hang up when agent is present

I have the following setup:
Client => Proxy server => Origin Server
I'm using the following Node.js libraries for each of these pieces, respectively:
isomorphic-fetch => http-proxy => http
Here's a gist of the setup in two files, one for each of the servers and one for the client: https://gist.github.com/headquarters/850cbb199ff397c6da56fb8d86113a7e
To run this locally, run node server.js in one shell and node fetch.js in another shell.
With the servers running, if I go to http://localhost:8818 in a browser, I get the sample response {"a":"b"}, so that's working. If I go to http://localhost:9818, I also get that response, so the proxying appears to be working fine. However, if I run DEBUG=* node fetch.js, which includes the HTTP proxy agent, the request fails (see output at https://gist.github.com/headquarters/850cbb199ff397c6da56fb8d86113a7e#file-failure-txt).
Without the agent property, the fetch command works fine on the command line. How do I go about debugging this socket hang up error?
Turns out I didn't read the https-proxy-agent docs closely enough. This line was a bit confusing: An HTTP(s) proxy http.Agent implementation for HTTPS--the PROXY itself can be either HTTP or HTTPS, but the origin server has to be HTTPS for this flavor of proxy-agent. For an HTTP origin server, I had to use http-proxy-agent. Thus, the socket hang up was probably coming from https.Agent trying to access an HTTP endpoint. It worked when I switched to http-proxy-agent.

socket.io-client-cpp does not connect to node app on Heroku via https

socket.io-client.cpp does not connect to node app on Heroku while Node JS socket.io-client does without any problem. Error is:
[2018-12-11 19:32:43] [connect] Successful connection
[2018-12-11 19:32:43] [error] handle_read_http_response error: websocketpp.transport:7 (End of File)
[2018-12-11 19:32:43] [info] Error getting remote endpoint: system:107
Changed URL from https to http://myapp.heroku.com - works now. Is it possible to connect via https as well? JS socket.io-client connects via secure connection without any problem.
Have built socket.io-client-cpp app with SIO_TLS in DEFINES (compiler flag: -DSIO_TLS) - connects via https fine now! This enables TLS support as mentioned here:
https://github.com/socketio/socket.io-client-cpp/pull/137

ECONNRESET proxy error between dev server and API

When I run my development server, I get the following error.
Proxy error: Could not proxy request /graphql from localhost:3000 to http://localhost:3010.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).
It is preventing me from proxying any requests from the development server to the API.
After debugging, I realized it was not a problem with the code because my colleague and I are working from the same repo and he does not have this error. Also, sometimes if I restart my terminal the error will go away before it comes back again.
Would greatly appreciate guidance on what is the root of this issue and how I can resolve it.
What I discovered, and what seems to have solved the problem, is that I was running too many different servers on ports that were too close together. My servers were running on port 3000, 3010, and 3009. I noticed that whenever the server at 3009 was running, I would get the above error. When I changed the port for that server from 3009 to 9999, all proxy errors ceased.

Node.js request SSL error: SSL23_GET_SERVER_HELLO:tlsv1

I am making a request to a remote server using https and request, and getting a new error after updating node and request:
nes.get err: [Error: 140735207432576:error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error:../deps/openssl/openssl/ssl/s23_clnt.c:741:
I already have the protocol set to SSLv3, so I'm wondering why it appears to be using tlsv1.
https.globalAgent.options.secureProtocol = 'SSLv3_method';
I've also tried adding this to request's options:
secureProtocol: 'SSLv3_method'
This error did not occur with earlier versions of Node.js and request, but now with node v0.10.15 and request 2.26.0, it has surfaced. Any ideas? Thanks!
Update -- narrowed this down to something that changes between request 2.14.0 and 2.16.0. 2.14.0 works and 2.16.0 does not work.
Make sure you are making a secure request to the correct port.
I've received this error when attempting to make a secure request to port 80 instead of port 443.
I would fire up Wireshark to verify that the bits on the wire are what you think they should be.

Resources