Permission denied for websocket

Hey everyone,

I’m trying to use the swipl websocket client library to connect to Neutralino, but it’s giving me a permission denied error. This doesn’t happen with the sample extension, or with any other websocket client I’ve tried, like the browser, and the ‘ws’ and ‘websocket’ npm modules).

I think this might be a bug in the implementation, because I tried stepping through with the debugger, but it just stops at the C code before returning that error. And it seems to specifically only happen in this case, I’ve tried the prolog client library on echo servers and it worked ok.

I’m using: SWI-Prolog version 8.4.2 for x86_64-linux

I want the code to: Connect to the websocket

But what I’m getting is:

user:main No permission to open websocket `'ws://loca
lhost:38321?extensionId=js.neutralino.plneu''

My code looks like this:

You can run it with Neutralino (neu run), and it’ll show the error

Websocket initialization is tricky. SWI-Prolog (AFAIK) nicely implements the standard, but some servers expect additional non-standard headers. If you have a working other client, use a network sniffer or logging/debugging on the server side to figure out what exactly is being exchanged and compare that to what SWI-Prolog exchanges. Then play around with the Prolog code to make the messages match. If the missing stuff seems to respect some de-facto practice, please let us know and/or submit a PR.

1 Like