MeshCentral: MeshCentral crashes when using the RelayPort

Describe the bug When you click the HTTPS link of a device the MeshCentral service crashes and restarts CleanShot 2022-06-30 at 10 55 20

To Reproduce

  1. enable RelayPort
  2. go to a device
  3. click HTTPS
  4. check log

Expected behavior Page should open

Log

ERR: /meshcentral/node_modules/meshcentral/apprelays.js:184
        for (var i in pendingRequests) { if (pendingRequests[i][2] == true) { pendingRequests[i][1].end(); } else { pendingRequests[i][1].close(); } }
                                                                                                                                          ^

TypeError: pendingRequests[i][1].close is not a function
    at close (/meshcentral/node_modules/meshcentral/apprelays.js:184:139)
    at handleNextRequest (/meshcentral/node_modules/meshcentral/apprelays.js:129:31)
    at Object.tunnel.onclose (/meshcentral/node_modules/meshcentral/apprelays.js:153:13)
    at Object.obj.close (/meshcentral/node_modules/meshcentral/apprelays.js:361:32)
    at WebSocket.<anonymous> (/meshcentral/node_modules/meshcentral/apprelays.js:423:117)
    at WebSocket.emit (node:events:527:28)
    at WebSocket.emitClose (/meshcentral/node_modules/ws/lib/websocket.js:172:10)
    at Socket.socketOnClose (/meshcentral/node_modules/ws/lib/websocket.js:781:15)
    at Socket.emit (node:events:527:28)
    at TCP.<anonymous> (node:net:715:12)

Node.js v17.9.1
Error: Command failed: /usr/local/bin/node /meshcentral/node_modules/meshcentral/meshcentral.js --launch 7

Server Software:

  • Virtualization: Docker container based on node:17-buster-slim
  • Network: Traefik reverse proxy in front (also proxying the RelayPort)
  • MeshCentral Version: 1.0.43
  • Node: v17.9.1
  • Browser: Google Chrome

Remote Device (please complete the following information):

  • Device: macBook Pro M1-Pro
  • OS: macOS Monterey 12.4

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (3 by maintainers)

Most upvoted comments

Looks like MeshCentral is receiving a HTTP header that it can’t parse correctly. It would be interesting to see what header is causing the issue. I can add code to deal with this gracefully, and skip and display any headers that cause issue.

Hi! I just updated to version 1.0.46 and problem with NAS server has been solved. Now everything works correctly.

Thank you very much!

I have a similar problem, I assume it will be the same.

When I web relay to a server the Meshcentral service restarts.

The server is a NAS OMV. I have another OMV NAS with the same version and it works fine.

The difference between one and the other is that the one that works is in the same network as the Meshcentral server, the one that causes the error is in another location and accesses from the outside through the reverse proxy.

I comment here the error that gives me:

-------- 2022-7-5 10:33:06 ---- 1.0.45 --------

_http_outgoing.js:514
    throw new ERR_INVALID_HTTP_TOKEN('Header name', name);
    ^

TypeError [ERR_INVALID_HTTP_TOKEN]: Header name must be a valid HTTP token ["{"response""]
    at ServerResponse.setHeader (_http_outgoing.js:532:3)
    at ServerResponse.header (/home/lergolas/node_modules/express/lib/response.js:771:10)
    at processHttpResponse (/home/lergolas/node_modules/meshcentral/apprelays.js:620:71)
    at processHttpData (/home/lergolas/node_modules/meshcentral/apprelays.js:490:17)
    at processRawHttpData (/home/lergolas/node_modules/meshcentral/apprelays.js:443:13)
    at WebSocket.<anonymous> (/home/lergolas/node_modules/meshcentral/apprelays.js:420:21)
    at WebSocket.emit (events.js:314:20)
    at Receiver.receiverOnMessage (/home/lergolas/node_modules/meshcentral/node_modules/ws/lib/websocket.js:720:20)
    at Receiver.emit (events.js:314:20)
    at Receiver.dataMessage (/home/lergolas/node_modules/meshcentral/node_modules/ws/lib/receiver.js:405:14) {
  code: 'ERR_INVALID_HTTP_TOKEN'
}

or a entry box to allow you to enter the port you want to relay… every device has specific ports…

ill add this to my feature request issue! i was literally just thinking this as i cant access say portainer running on 9000,

this issue is actually a BUG