Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

message.reply appears to not find connection #91

Closed
LivInTheLookingGlass opened this issue Sep 23, 2016 · 6 comments
Closed

message.reply appears to not find connection #91

LivInTheLookingGlass opened this issue Sep 23, 2016 · 6 comments

Comments

@LivInTheLookingGlass
Copy link
Collaborator

LivInTheLookingGlass commented Sep 23, 2016

It's unclear whether this is a bug in the javascript or python implementation. maybe both.

Steps to replicate:

Use the following python script to generate 8 nodes:

import time
from py2p import mesh

num_nodes = 8
start_addr = 6666

nodes = [mesh.mesh_socket('localhost', start_addr)]
for j in range(1, num_nodes):
    new_node = mesh.mesh_socket('localhost', start_addr + j)
    nodes[-1].connect('localhost', start_addr + j)
    nodes.append(new_node)
    time.sleep(0.5)

Then, in a nodejs instance, run the following:

const mesh = require('./mesh.js');
var conn = new mesh.mesh_socket('localhost', 4444);
conn.connect('localhost', 6666);
conn.send(['hello']);

Over in python-land, find a node not directly connected to conn, and call:

nodes[x].recv().reply('hello', 'again')

This should print a message about how the throughput is not guaranteed.

Problem is, it should be working. I know that python makes the request, because it uncovered a Javascript bug. But it's not making the connection afterwards.

My two theories are:

  1. connect isn't letting it override the max connection limit
  2. The request isn't being processed correctly.

If it's the first one, the bug will be present in both implementations.

if it's the second one, then I'm not sure.

@LivInTheLookingGlass
Copy link
Collaborator Author

I don't see where the bug is showing up in connect. Thinking back on it, that limit is checked in __handle_peers.

@LivInTheLookingGlass
Copy link
Collaborator Author

Looks like a bug on the Javascript side of things. It's got a buffer full of data and isn't processing it. Seems like my callback scheme needs a while loop somewhere in there.

@LivInTheLookingGlass
Copy link
Collaborator Author

Adding a while loop seems to have fixed the problem in the short term, but I'm getting some socket errors now that I don't know how to trace back. I'm going to push this commit for now, but this is only part of a bugfix

LivInTheLookingGlass added a commit that referenced this issue Sep 27, 2016
@LivInTheLookingGlass
Copy link
Collaborator Author

Specifically I get:

> Error: Error: write EPIPE
Error: Error: write after end

@LivInTheLookingGlass
Copy link
Collaborator Author

LivInTheLookingGlass commented Sep 27, 2016

It's totally possible this was a one-off though, because I've tested this fix four times and only gotten the issue once. Unfortunately I didn't have debug text turned on at the time so I couldn't trace it down more specifically.

I really need to get a logging method on this...

@LivInTheLookingGlass
Copy link
Collaborator Author

Appears to be disconnecting because of a bug in the handshake code. Javascript implementation appears to not be sending the protocol id in some instances. Obviously it's sending it in some because it couldn't connect to the network at all otherwise, but it's also getting it wrong sometimes.

This will be moved to a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant