bethe Posted November 22, 2022 Share Posted November 22, 2022 Following two app.js both run fine on my local computer. But when I upload them to Tommy, the first script went wrong while the second is OK. So I wonder what could cause this? They seem to do the same thing. (1) app.js using net var net = require("net"); var server = net.createServer(function (socket) { socket.on("data", function (data) { let resp = "HTTP/1.0 200 OK\r\n" + "Content-Type: text/html\r\n" + "Content-Length: 10\r\n" + "\r\nIt works!!"; socket.write(resp); }); }); server.listen(3000, '127.0.0.1', function () { console.log("listening on port 3000"); }); (2) app.js using http const http = require('http'); const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/html'); res.end(`Node.js works!`); }); server.listen(3000, '127.0.0.1', () => { console.log("listening on port 3000"); }); Quote Link to comment Share on other sites More sharing options...
Krydos Posted November 23, 2022 Share Posted November 23, 2022 What did it say in the logs for option #1? Quote Link to comment Share on other sites More sharing options...
bethe Posted November 24, 2022 Author Share Posted November 24, 2022 On 11/23/2022 at 4:40 PM, Krydos said: What did it say in the logs for option #1? Error ID: 9867a925 Details: Web application could not be started by the Phusion Passenger(R) application server. Please read the Passenger log file (search for the Error ID) to find the details of the error. I look into the logs and find "App 8492 output: Error: listen EADDRINUSE: address already in use 127.0.0.1:3000" But both scripts listen on that address and port, #2 runs without errors. Quote Link to comment Share on other sites More sharing options...
Krydos Posted November 25, 2022 Share Posted November 25, 2022 Did you try another port such as 3001 with code option #1? Quote Link to comment Share on other sites More sharing options...
bethe Posted November 25, 2022 Author Share Posted November 25, 2022 6 hours ago, Krydos said: Did you try another port such as 3001 with code option #1? Using port 3000: Quote 15549/T2h age/Cor/App/Implementation.cpp:221: Could not spawn process for application /home/rus.helioho.st/httpdocs: The application process exited prematurely.Error ID: 525ad134Error details saved to: /tmp/passenger-error-cpo06h.html App 116961 output: 116961/T1 age/Spa/SpawnEnvSetupperMain.cpp:747: shellName = 'false' detected as supporting '-l': falseApp 116961 output: node:events:491App 116961 output: throw er; // Unhandled 'error' eventApp 116961 output: ^App 116961 output:App 116961 output: Error: listen EADDRINUSE: address already in use :::3000 Using port 3001: Quote 105131#0: *20020 upstream timed out (110: Connection timed out) while reading response header from upstream 100376/Ty age/Cor/App/Implementation.cpp:221: Could not spawn process for application /home/rus.helioho.st/httpdocs: A timeout occurred while spawning an application process. Error ID: 88f54452 Error details saved to: /tmp/passenger-error-EWUMQ7.html App 97403 output: 97403/T1 age/Spa/SpawnEnvSetupperMain.cpp:747: shellName = 'false' detected as supporting '-l': false App 97403 output: listening on port 3001 So I guess Passenger just don't work with such toy scripts. Maybe if some http server capabilities is checked during startup, my script #1 "exited prematurely." Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.