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

Protocol selection failed testing new protocol (Chat) #8

Closed
brokenprogrammer opened this issue Nov 23, 2021 · 11 comments
Closed

Protocol selection failed testing new protocol (Chat) #8

brokenprogrammer opened this issue Nov 23, 2021 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@brokenprogrammer
Copy link
Member

Tried to run the application and got the following error message:

> feldmanchain-on-prem@1.0.0 start
> node ./src/peer.js

Listener ready, listening on:
/ip4/192.168.81.24/tcp/61111/p2p/QmeVH7fbKuiLyz3agCELWQb1fHy7tSoY4PSCwnbpyTHPVZ
/ip4/192.168.56.1/tcp/61111/p2p/QmeVH7fbKuiLyz3agCELWQb1fHy7tSoY4PSCwnbpyTHPVZ
/ip4/127.0.0.1/tcp/61111/p2p/QmeVH7fbKuiLyz3agCELWQb1fHy7tSoY4PSCwnbpyTHPVZ


Discovered: 12D3KooWQu3wjQYbi23VVZCvxV9Ta3Tu4Z4fwuat69Zydn4apEWR


C:\Users\oskar.mendel\Documents\Github\feldmanchain-on-prem\node_modules\multistream-select\src\select.js:50
  throw errCode(new Error('protocol selection failed'), 'ERR_UNSUPPORTED_PROTOCOL')
                ^

Error: protocol selection failed
    at module.exports (C:\Users\oskar.mendel\Documents\Github\feldmanchain-on-prem\node_modules\multistream-select\src\select.js:50:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Connection.newStream [as _newStream] (C:\Users\oskar.mendel\Documents\Github\feldmanchain-on-prem\node_modules\libp2p\src\upgrader.js:251:40)
    at async Connection.newStream (C:\Users\oskar.mendel\Documents\Github\feldmanchain-on-prem\node_modules\libp2p-interfaces\src\connection\connection.js:173:34)
    at async Libp2p.<anonymous> (file:///C:/Users/oskar.mendel/Documents/Github/feldmanchain-on-prem/src/peer.js:48:22) {
  code: 'ERR_UNSUPPORTED_PROTOCOL'
}
@GGAlanSmithee
Copy link
Contributor

GGAlanSmithee commented Nov 23, 2021

@brokenprogrammer thanks for reporting

Interesting. Your output shows one additional listening address. My (working) output is:

Listener ready, listening on:
/ip4/192.168.81.23/tcp/63688/p2p/QmZzRKpVkhE1oF2uh526VuSGK6UebxrRFK4RFg91p8UtWF
/ip4/127.0.0.1/tcp/63688/p2p/QmZzRKpVkhE1oF2uh526VuSGK6UebxrRFK4RFg91p8UtWF

I'm fumbling in the dark here, so will have to investigate, but maybe it has something to do with your network settings.

@GGAlanSmithee
Copy link
Contributor

GGAlanSmithee commented Nov 23, 2021

Also, @brokenprogrammer did you only run one instance on your computer? The line

Discovered: {peerId}

indicates that you discovered a peer, which seems a bit strange.

@GGAlanSmithee
Copy link
Contributor

GGAlanSmithee commented Nov 23, 2021

Additional info:

Seems likely that the issue is due to @brokenprogrammer having multicast enabled on his computer (using mdns with zeroconf). Will test this theory later, when I have a bit more time.

EDIT: The reason for this seems to be that port 5353 is the designated port for mdns. Other users have had similar issues with running multiple services on this protocol, though unrelated to libp2p

@GGAlanSmithee
Copy link
Contributor

@brokenprogrammer I added a simplified mdns test in 52188f4

Can you please pull it (latest commit on branch feature/chat) and run npm run start:mdns-test? Just to further isolate the issue. I am faily certain that is the source of the error, but just to make sure.

@GGAlanSmithee
Copy link
Contributor

Here's the output when running the above example from a computer running win7 that's not on the office net:

image

@GGAlanSmithee GGAlanSmithee added the bug Something isn't working label Nov 23, 2021
@GGAlanSmithee
Copy link
Contributor

Interestingly, the peer that your computer discovered is the IPFS peer running on my computer:

image

This somewhat proves that we will be able to use this as a discovery mechanism for a on-prem installation of the feldmanchain, but it also shows that a libp2p peer defaults to a configuration compatible with IPFS. This is reasonable since they are behind this lib. Probably something to look into further though. I also doubt this has something to do with the actual issue discussed in this thread. I will turn off the node while testing.

@GGAlanSmithee
Copy link
Contributor

GGAlanSmithee commented Nov 23, 2021

@brokenprogrammer I actually think I am chasing ghosts, and that I should learn to read error messages.

The exception you posted points to

async Libp2p.<anonymous> (.../feldmanchain-on-prem/src/peer.js:48:22)

which corresponds to the line

const { stream } = await node.dialProtocol(peerId, "/chat/1.0.0")

In that context, the error message does make sense, since in the code, we attempt to dial in to the protocol /chat/1.0.0. This is copy/pasted from an official example, so I expect it to work out of the box (as it does on my computers) but that is ofcourse an assumption, and this does provide me with something to look into further.

@GGAlanSmithee
Copy link
Contributor

GGAlanSmithee commented Nov 23, 2021

@brokenprogrammer

I am quite certain I know what is happening now:

  1. When you run the script, and it connects, it discovers my IPFS peer
  2. On doing so, it attempts to dial into it (using its peerId) on the protocol /chat/1.0.0
  3. Since my IPFS peer does not handle the protocol /chat/1.0.0, the proper error message - ERR_UNSUPPORTED_PROTOCOL -is returned.

If this is correct, you should be able to try this tomorrow and expect it to work (since my IPFS peer now is turned off). Please be aware that you do not discover any peer when running just one instance of the script.

This does not, however, explain why it failed on your other computer, since, if I understand it correctly, that one is not connected to the office net?

@brokenprogrammer
Copy link
Member Author

I see that makes sense, I never ran it on my personal computer only on my work pc.

@GGAlanSmithee
Copy link
Contributor

Ok, great, hopefully it works now then!

@GGAlanSmithee
Copy link
Contributor

image

Seems that was the issue indeed, and it seems to be working now 💯

I'll open a new issue regarding having only compatible peers discover each other

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants