Skip to content

Socket hang up #2

@boygiandi

Description

@boygiandi

When I run this proxy, I get this error

Error: socket hang up
at createHangUpError (_http_client.js:330:15)
at Socket.socketOnEnd (_http_client.js:431:23)
at Socket.emit (events.js:202:15)
at Socket.EventEmitter.emit (domain.js:446:20)
at endReadableNT (_stream_readable.js:1129:12)
at processTicksAndRejections (internal/process/next_tick.js:76:17)

I tried to fix it and I found this, if I replace the target in original code, from this

  const proxy = httpProxy.createProxy({
    agent: http.globalAgent,
    target: { host, port },
    ws: true
  });

to this

  const proxy = httpProxy.createProxy({
    agent: http.globalAgent,
    target: `http://localhost:${port}`,
    ws: true
  });

It works. I don't really understand why. Maybe you can help me explain it.
I fixed the code in my case, and I also replace the backend to localhost if it's the same with proxy IP.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions