bykof / cordova-plugin-webserver

A webserver plugin for cordova
Other
124 stars 49 forks source link

Websocket response #63

Closed christophsaile closed 4 years ago

christophsaile commented 4 years ago

Hello,

I am currently struggeling to use this plugin to establish a websocket connection. My goal is to send a ws request to the local server and create a connection. If I use the response header from your example I get the following error:

90226636-9132ec80-de13-11ea-91d5-4f4ead94e878

I have already tried to change the status of the response header to "101 Switching Protocols" but that did not work for me.

90952740-6f1a1980-e466-11ea-868f-9383775bf42e

Do you have any idea if its possible to create a websocket connection between two devices with your plugin?

thanks in advance, Christoph

bykof commented 4 years ago

Hi Christoph, it's poorly not possible to create a websocket connection because the webserver needs to open up a http socket and hold it until one of the participants close it. If you send a request to the plugin, the request will be send to the JavaScript runtime, after the request has been sent, the socket is already closed and therefore it's not possible to establish a websocket connection. sorry for that.

christophsaile commented 4 years ago

Ahh ok makes sense. Thanks for your fast response.