mkuklis / phonegap-websocket

Websocket PhoneGap plugin for Android
203 stars 78 forks source link

Support for Android 4.4 and later #56

Open mburger81 opened 6 years ago

mburger81 commented 6 years ago

Hi, we are developing a cordova app which has to use a Websocket Service deployed by a 3rd part on cloud, this service for security reason is checking the origin header. Using native WebSockets on Android 4.4 in WebView is setting always the origin header "file://". We didn't found until now any solution to remove this header on android. But we found your cordova plugin where we can set the header and remove them, this is working because you are using jettys WebsocketClient instead of native Websockts, but as you write on your readme from 4.4 this plugin is not used anymore.

So I would like to aks you two things:

  1. Do you have more experience using WebSockets and Cordova plugins, do you think there is a way to remove this header with a cordova plugin, for example intercepting the request from SystemWebView and remove the origin or something else?
  2. If first does not work, do you thinkg we can use your plugin also on KitKat until Android 7.x.x

Thx a lot for your help and time

mkuklis commented 6 years ago

Hi @mburger81

Unfortunately I don't think there is a way to control the origin header when using a nativeWebView. One solution could be to setup a proxy between your app and the remote service. The proxy could set a different origin and forward the request.

You are welcome to use this plugin and it should work fine with Android >= 4.4 although I haven't touched it in a while.

mburger81 commented 6 years ago

@mkuklis sorry for my late response. Does the plugin handle cookies?!?

mkuklis commented 6 years ago

@mburger81 there is no support for cookies from the top level API of this plugin but it uses https://github.com/TooTallNate/Java-WebSocket so you should be able to access cookies in Java. Some info here: https://github.com/TooTallNate/Java-WebSocket/issues/258

Just curious what do you need cookies for?