PrismarineJS / PrismarineJS/node-minecraft-protocol

Missing ping timeout callback when server is running but not responding to pings

Open
#329 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
1.4k
Forks
290
Avg merge
4d 8h
Merged PRs (30d)
7

Description

ping.js does not appear to always call its callback method, it will be called with an error when a) the port is closed (example: options {host:'github.com', port:25565}), b) when a protocol error occurs (example: {host:'github.com', port:80}), but not c) when the server is running but does not acknowledge the pings.

To test this with a server, from https://github.com/PrismarineJS/node-minecraft-protocol/issues/327#issuecomment-174310946 made this modification

diff --git a/src/createServer.js b/src/createServer.js
index 5b56fdd..ef2b84e 100644
--- a/src/createServer.js
+++ b/src/createServer.js
@@ -39,7 +39,7 @@ function createServer(options) {
   server.on("connection", function(client) {
     client.once('set_protocol', onHandshake);
     client.once('login_start', onLogin);
-    client.once('ping_start', onPing);
+    //client.once('ping_start', onPing);
     client.on('end', onEnd);

     var keepAlive = false;
NODE_DEBUG=mc-proto node examples/server/server.js

Testing the ping client:

> node-minecraft-protocol $ node
// connection timeout calls callback
> require('./').ping({host:'github.com', port:25565}, function(){console.log(arguments)})
undefined
[…wait a few minutes…]
> { '0': 
   { [Error: connect ETIMEDOUT 192.30.252.128:25565]
     code: 'ETIMEDOUT',
     errno: 'ETIMEDOUT',
     syscall: 'connect',
     address: '192.30.252.128',
     port: 25565 } }

// protocol error calls callback
> require('./').ping({host:'github.com', port:80}, function(){console.log(arguments)})
undefined
> { '0': { [Error: Deserialization error for status.toClient : Read error for name : 84 is not in the mappings value] field: 'status.toClient' } }
{ '0': { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' } }

// using above example (commenting out ping_start), never responds (waited 10+ minutes)
> require('./').ping({host:'localhost', port:25565}, function(){console.log(arguments)})
undefined

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ping.js and trace the callback path when a server accepts the connection but does not acknowledge pings. Reproduce the behavior with the modified src/createServer.js setup and examples/server/server.js, then verify that the ping callback completes with an error instead of waiting indefinitely.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.