express icon indicating copy to clipboard operation
express copied to clipboard

ERR_EMPTY_RESPONSE every time i try to access from a device not local

Open jman13378 opened this issue 1 year ago • 16 comments

so im trying to create an express server but i get ERR_EMPTY_RESPONSE(from a VPN) on other devices and my friends got ERR_CONNECTION_TIMED_OUT

how can i fix this

jman13378 avatar Oct 02 '22 23:10 jman13378

can you help with a screenshot i want to confim something

enyoghasim avatar Oct 04 '22 06:10 enyoghasim

Screenshot_20221004_181614

const express = require('express')
const app = express()
const fs = require('fs')
app.use(express.static('public'))
var lel = app.get('/', function (req, res) {
}).get('/site', function (req, res) {
  fs.readFile('./public/site.html', async function(err, data) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.write(data);
    return res.end();
  });
  

}).get('/api/get/guilds', async function (req, res) {
  res.send(`${await client.guilds.cache.size}`)
}).get('/api/get/members', async function (req, res) {
  res.send(`${await client.users.cache.size}`)

}).get('/api/get', function (req, res) {
  fs.readFile('./public/api/get/', async function(err, data) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.write(data);
    return res.end();
  });

}).listen(port,"0.0.0.0", ()=>{
  console.log(`Listening port on ${lel.address().port}`)
});

jman13378 avatar Oct 04 '22 22:10 jman13378

sorry for asking is the ip a publicly accessible ip address?

or that of localhost

enyoghasim avatar Oct 04 '22 22:10 enyoghasim

that was my pc's ipv4 but my public ip address does the same thing. My ipv4, localhost, and public address work on local devices

jman13378 avatar Oct 04 '22 22:10 jman13378

ok can you try using ngrok to expose the local port and lets see how that goes?

enyoghasim avatar Oct 04 '22 22:10 enyoghasim

it works but i would rather use my ip

jman13378 avatar Oct 04 '22 23:10 jman13378

i guess the main issue is the ip adress.

i guess its not being exposed

enyoghasim avatar Oct 04 '22 23:10 enyoghasim

It is also possible there is a firewall involved, either on the device itself or the network between the two machines. If you are able to at least get a reaponse on loopback (i.e. 127.0.0.1), then the issue is outside of the express.js framework and something network, machine, or node.js.

dougwilson avatar Oct 04 '22 23:10 dougwilson

image image image

jman13378 avatar Oct 04 '22 23:10 jman13378

Hi @jman13378 I am certainly sorry you are having trouble. It is unfortunately we are not sure what the issue is exactly that you are experiencing and we are not also experiencing. That puts us in a hard place to help. If you believe this is an issue in Express.js, it may help if you can help provide pointers for where you are seeing the issue in our code and we can perhaps work towards what code changes we need to make, or you're always welcome to contribute such a change directly. Other than that, I'm not sure how else we can help.

dougwilson avatar Oct 04 '22 23:10 dougwilson

It is also possible there is a firewall involved, either on the device itself or the network between the two machines. If you are able to at least get a reaponse on loopback (i.e. 127.0.0.1), then the issue is outside of the express.js framework and something network, machine, or node.js.

yea @dougwilson because ngrok also works according to him

enyoghasim avatar Oct 04 '22 23:10 enyoghasim

Well, here is a test @jman13378 : see if the following code has the same issue or not. This will narrow down for if the Express.js project can assist or not:

const http = require('http')
const app = http.createServer((req, res) => res.end('Hello, world!'))
app.listen(3000, "0.0.0.0")

dougwilson avatar Oct 04 '22 23:10 dougwilson

const http = require('http')
const app = http.createServer((req, res) => res.end('Hello, world!'))
app.listen(3000, "0.0.0.0")

not that

jman13378 avatar Oct 05 '22 00:10 jman13378

its most likely an ISP issue or Firewall

jman13378 avatar Oct 05 '22 00:10 jman13378

were you able to solve the issue ? or is it still not working ?

Looking on my side like other people said it is most likely some kind of firewall / blocking the request

sheplu avatar Oct 19 '22 10:10 sheplu

I will try in my pi but other than that I have not fixed it

jman13378 avatar Nov 01 '22 12:11 jman13378