electron+figwheel on Mac causes websocket connection error - node.js

Background
I am trying to integrate figwheel with electron(atom-shell). I use
lein new figwheel hello-world -- --reagent
to generate figwheel part, and copied the electron part from electron quick start. The resulting project is here.
Question
Run the project by:
Open a terminal and start figwheel lein figwheel
Open another terminal, start Electron by electron ..
However it fails on Mac. The electron part shows the following log:
[5848:0720/220633:INFO:CONSOLE(62)] "WebSocket connection to 'ws://localhost:3449/figwheel-ws/dev' failed: Connection closed before receiving a handshake response", source: file:///Users/foo/repos/cljs-douban/resources/public/js/compiled/out/figwheel/client/socket.js (62)
[5848:0720/220635:INFO:CONSOLE(82)] "Figwheel: trying to open cljs reload socket", source: file:///Users/foo/repos/cljs-douban/resources/public/js/compiled/out/figwheel/client/utils.js (82)
However, the same project works on Linux. Googled and no correct result, Please kindly help.

After googled for 'MAC websocket connection error', I got a similar problem here.
And it is the proxy I set screwed 'localhost', which causes connection error. Disable the proxy fixed the issue. Sorry for any inconvenience.

Related

Connection refused on localhost

I am trying to work on my nodejs and reactjs app at school but everytime I run the server, I get an error with
localhost:PORT/net::ERR_CONNECTION_REFUSED
Is the wifi refusing the connection on localhost?
PS: The react side renders correctly
If you're using WSL (linux on windows), restart its service LxssManager Servie (run services.msc) and try again.
Try changing the url from localhost to 127.0.0.1 . If it works, then it means your environment is not resolving localhost to 127.0.0.1
Or Try with changing the PORT Number
For those of you that the approved solution didn't work for (changing localhost to 127.0.0.1) I was able to fix this just by restarting my computer. Not sure what caused the issue but the day before today my app was working fine and then today I got hit with this error. Restarting fixed the issue.
In my case I have an error with require in setupProxy.js
In my case, deleting the node_modules and then reinstalling using npm install worked.
I was also facing this problem on mac m1 from last 2 days, so finally i ended fixing the issue by :-
Run 'npm start' from default shell(/bin/bash) on vs code.
You can also try to update the node version.
You may need to change the port for application only if some other application is running on default port(3000)
In my case, I resolved the issue using "npm start" command again in terminal of vs code and it works.
In my case I had made changes to the setupProxy.js that caused the problem. Try reverting back to something that is working, such as:
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:5000',
changeOrigin: true,
})
);
};
Rebooting the system (linux) worked for me. Consider rebooting first.
the problem of "localhost refused to connect." is occur because of command prompt that you closed so you must keep open your command prompt after hit "npm start" command till you work in "App.JS" file.
i'm sure this will work 100%.

Socket.IO Failed to load resource: the server responded with a status of 404 (Not Found)

To start I'm not a coding expert so excuse me if this was a newbie question.
I have installed a nodejs app into my VPS (digital ocean), after uploading everything (both server side and client side) seem to be running but I'm having an issue.
The dependencies are managed using bower so installed everything in the root directory of Apache server. As I use the "Inspect Element" in my browser to see
the console I get a first error of:
http://104.131.66.68/manager/bower_components/socket.io-client/dist/socket.io.min.js Failed to load resource:
the server responded with a status of 404 (Not Found)
I checked the bower_components folder in my server and the folder socket.io-client exists! But when I checked through my browser to see the source files it is not there! Other dependencies are available.
These are the errors that appear, the socket.io error at the top most i suspect the reset are due to the same problem and lastly is the API Key (i intend to handle that after this).
your help is highly appreciated!!
Thank you
<script src="/socket.io/socket.io.js"></script> use this to serve the socket.io client. If it does not work, you are having something wrong somewhere.

Node.JS code fails without error on Ubuntu

I have the simplest code for firebase :
var Firebase=require('firebase');
var Ref=new Firebase('http://mydb.firebaseio.com/requests');
Ref.push({name:"checkin",type:"mandatory"},function(response){
console.log(response);
});
and I'm running it with SSH in command line on my Ubuntu 12.04 server. For some reason the push method runs but doesn't push anything and doesn't even show an error. I tried logging the error to a file but the file remains empty. I also tried catching an uncaught exception from the process, no luck. There basically isn't an error to show. How should I catch an error so I can investigate further ?
Extra information :
-Node.JS version installed on the server is 12.4 .
-One thing I noticed is there is no certificate file on the server and for example I can't use curl with an https url or PPA to download a package.
-Ubuntu 12.04.
-When I push to firebase using a PHP script it works fine but nodeJS fails to do it.
-The server is in a hospital's internal network and connects to internet through a proxy. Certain HTTPS websites are allowed on port 80 , the rest are blocked . Some similar policies might be in place for other ports and protocols.

How to resolve Failed to connect to IPC Port Error

I am getting one issue in my application Setup USING wix
When i run my setup i got the below exception message:-
Failed to connect to IPC Port System cannot find the file specified:mscorlib.dll
After getting this message i got a windows message
There is a problem with this installer setup.
A program run as a part of system did not finish as expected.
Is there any way to resolve it.
Get to Dos command line then type in
Netsh winhttp show proxy ( Press Enter )
then type in
Reset proxy ( Press Enter )
This will release the Internet Proxy IP settings, restart the PC if needed.

Node.js, WebSocket Location Issue?

I created a server using Node listening on port 8000, localhost. Verified it's running properly, but I cannot access the WebSocket on the client (Chrome 5). Tried several implementations from various Git repos, node + websocket, socketIO, articles, etc. Nothing.
No port conflicts (sudo lsof -i tcp);
Tried server.listen(8000, "*");
Pointed to ws = new WebSocket("ws://:8000/test");
Debian Lenny, Apache22
Node v0.1.98-31-g1c6671a
I'm thinking there may be a conflict with url rewrite. Or possible permissions. Any ideas?
I had a similar issue on Ubuntu 10.04 LTS 32-bit and Chrome 5.0.375.125 and found out it is a bug in Chrome.
Here's how you can test and work around the problem. I used WebSocket with PHP and later Node.JS:
PHP: Download a tutorial file from http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/ and extract it in a folder called 'socket' in your webroot. This folder now contains a readme.txt and the folders 'server' and 'client'. Now start the script in the console according to the readme (for me the command was: sudo php -q /var/www/socket/server/startDaemon.php ). It should print 'Start listening on Socket.' . Leave the console window open. Now go to localhost/socket/client/client.php in Chrome. It should say 'Socket Status 0' and if you look in the console you see no new messages (no connection was made).
Now here comes the trick: open a second Chrome tab. Point this tab to the same url: localhost/socket/client/client.php (It also says 'Socket Status 0'). And then close it again. Your original tab should now say 'Socket Status: 1 (open)' and in the console you see a handshake was made. WebSocket now works.
I repeated the same trick as above but this time using Node.JS with the Socket.IO script. The chat example included in Socket.IO-node ( github.com/LearnBoost/Socket.IO-node ) had the same issue, hanging at the 'Connecting...' stage. Opening a second tab to the chat box and then closing it again solved the problem and the chat box proceeded to load properly. The Node.JS server confirmed the connection in the console. From then on WebSocket worked fine.

Resources