Git Product home page Git Product logo

websocket-for-android's People

Contributors

evgk avatar knowledgecode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

websocket-for-android's Issues

Support for origin field

The current library does not support the WebSocket "origin" field as per the RFC, any way this can be added?

My team received an error while trying to connect to a WebSocket via VPN

Hello, my team is developing a mobile application using Cordova and your plugin. I just received a report from my team this morning, she said she successfully tested a WebSocket connection in the application on her own development server. But, when she tried to test it on the company development server via VPN, she received an error that returns a connection error from a WebSocket, and she said it is quite hard to debug. Is there any way to detect the type of error and has anyone faced this issue via VPN before?

[Problem] Text frame aggregation disabled

When we use this plugin we have a problem.
Socket closed with error code 1008 and message Text frame aggregation disabled.

Can you describe how can be fix or resolve it.

Yes, we can crop data but we want get it without cropping.

Doesn't work when AndroidManifest.xml debuggable is set to false

I was tryin gto release my application and websockets stoped working when I switched from
<application android:debuggable="true"
to
<application android:debuggable="false"
as I was going to release the aplpication
When I switched back to true websockets worked again
Any help appreciated.

my issue with the websocket-for-android

hi,
i have a problem: the app in some android device is running normal,but "in some devices"(android 4.0.3) i can conenct normally,receive infomation from other people using web normarlly , but
Failed to send message with "some devices"!
please help me ! thanks!

my cordova version 5.1.1 ,with cordova ceate android project target android 4.0.2.
if you find the probleam ,send email for me .email:[email protected]

Any dependency on Android APIs?

I've test your plugin in two android devices, one tablet with a 4.1.1 version number, and a phone (S3) with a 4.3 version. In the first case, the sample (ws://echo.websocket.org) is runing ok, but in the second not (it seems that makes the create call, but no open event is called). Maybe there are any dependency on the android version? I think no, but i want to be sure.
Other thing is related to the loading of websocket.js file. In the Web Console (logcat) is shown one error:
E/Web Console(17298): Uncaught ReferenceError: require is not defined at file:///android_asset/www/js/websocket.js:29

The error is presented in both case (tablet and phone)

Thank you for your support. You're doing a great job!!!

WebSocket not working

I'm trying:

if("WebSocket" in window){
//code here
}else{
//erro here
}

Getting error. WebSocket not present in window.

-Cordova version 7.0,1
-Platform: android 6.2.3
-Android 4.1.1 (My device)

Newlines in JSON messages result in syntax error

If the server sends JSON that has newlines in it, Cordova Javascript will barf with a syntax error. The createJsonForMessage() function should correctly escape newlines before sending.

Thanks for making this, by the way! Exactly what I needed!

org.eclipse.jetty.util.thread package missing

Once installed with 'cordova plugin add com.knowledgecode.cordova.websocket', you get following classes placed in directory that doesn't match its package 'org.eclipse.jetty.util.thread'
classes affected: QueuedThreadPool, ThreadPool, Timeout.

The project compiles from CLI and there are correct classes complied under platforms ▸ android ▸ ant-build ▸ classes ▸ org ▸ eclipse ▸ jetty. But the problem is visible under ▸ platforms ▸ android ▸ src ▸ org ▸ eclipse ▸ jetty ▸ util where mentioned classes are placed and thread folder is missing.

It causes eclipse project errors.
I am using Mac environment for development.

Error "websocket is not defined"

I am Developing a hybrid app using phonegap. I developed whole app using browser and run it using apache. I also implemented websocket using html5. Socket works well in browser. For using it native with cordova i used your plugin. But when i try to work with websocket, i get error "Websocket is not defined" on line
var socket = new WebSocket("ws://localhost:9000/");

What i am doing wrong??? please help me

ws.close then ws.create hangs

Hi,
When we pass a ws.close() to the plugin, it closes correctly (we see a disconnection on our server with code:1000 normal disconnection).
When we try and re-establish a connection (ws.create) nothing hits the server and the plugin appears to hang. We think this was not the case prior to the last update adding the origin when it looks like you also refactored some of the code.
Cheers
Rob

wss - goes to onerror after compile

Hi,

When trying to run the plugin on wss, the wesocket goes right to on error.

I found in the logcat this message:
Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

Couldn't find any solution to this issue.

Any idea ?

Thanks,
Tomer

Websocket close ifself with code 1005

Hi,

I use this plugin in cordova,and found the websocket close itself with 1005,I search the RFC doc it means CLOSE_NO_STATUS, I have realy no means, any help would be appreciated?

This is the event from onclose:

{"reason":"","code":1005,"wasClean":true,"path":{"length":0},"cancelBubble":false,"returnValue":true,"srcElement":{"binaryType":"blob","protocol":"","extensions":"","bufferedAmount":0,"readyState":3,"url":"ws://192.168.188.20:7001/ws","URL":"ws://192.168.188.20:7001/ws"},"defaultPrevented":false,"timeStamp":1487753895945,"cancelable":false,"bubbles":false,"eventPhase":2,"currentTarget":{"binaryType":"blob","protocol":"","extensions":"","bufferedAmount":0,"readyState":3,"url":"ws://192.168.188.20:7001/ws","URL":"ws://192.168.188.20:7001/ws"},"target":{"binaryType":"blob","protocol":"","extensions":"","bufferedAmount":0,"readyState":3,"url":"ws://192.168.188.20:7001/ws","URL":"ws://192.168.188.20:7001/ws"},"type":"close"}

I sniffer it and find the cordova app close it first:

image

websocket topic

Hello!
By using this plugin, is there any possibility to send/receive messages to/from a specific topic after making a connection and subscribing to that topic?

Thanks in advance!

Issue with the cookie when cookie-value contains "=" character

When cookie-value contains "=" character(in my case, session-cookies like that are generated by the Play framework, which generates session-cookies like that:
PLAY_SESSION=<<session_id>>-connected=<>&websockid=<<socket_id>>;), this code fails:

private static void setCookie(Map<String, String> cookies, String host, String path, boolean secure) {
    String url = String.format("%s://%s%s", secure ? "https" : "http", host, path);
    String cookie = CookieManager.getInstance().getCookie(url);

    if (cookie != null) {
        for (String c : cookie.split(";")) {
            String[] pair = c.split("=");

            if (pair.length == 2) {
                cookies.put(pair[0].trim(), pair[1].trim());
            }
        }
    }
}

Since pair.length won't be 2. Suggested PR:
#35
fixes it.

What happens to IOS when adding this plugin

I use CLI and add the plugin. When I add it I get two log lines telling it is added both to android and ios. For IOS there is a built in function for web socket already. Will this plugin be used instead of the build in web socket?

When I have built both IOS and Android it is working on the both plattforms.

SSL Cert issues.

Is there a way to ignore ca issues when using SSL/wss.

I have an issue with wss, though only with one server. I suspect it's to do with the CA. It would be nice if I could ignore the CA instead of not using SSL/wss

Support for Android 4.4 and later

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

onOpen not being fired

I'm having a really weird behaviour, where sometimes onOpen is fired and sometimes it isn't.
Nothing appears on LogCat nor on Cordova log.

Tried on a Samsung Mega running Android 4.2.2, the compiled app has the right permissions, as it sometimes connects to the server.

not be able to create WebSocket connection

[Question] I am new to github and I do not know where to ask questions, So I am asking here, help me out on this issue,

I added WebSocket plugin to my android project and made changes on js file on cordova 3.6.3 and android 4.3, but I am not able to create WebSocket connection.Is there anything I need to add on native side to initiate WebSocket connection.

Thanks in Advance.

@SuryaAdabala
Thank you for using this plugin. Your post was moved here.
Now I can't answer your question because of too few clues. Could you paste the code snippet here? What error message are you getting?

Question: Can I use SockJS with your websockets?

Do you know if it's possible to use the SockJS protocol over your websocket plugin? SockJS provides transparent fallbacks (XHR, etc) in cases were we can't use websockets (e.g. old Android versions). I want the fallback, but I'd like to use websockets wherever possible. So I guess I need for SockJS to use your Websocket object, but before I dig in, do you know already if it's possible? Tried Socket.IO?

Message too large error

Hi,
I'm encountering the following error:

W/System.err( 5875): 2014-10-08 10:35:19.388:WARN:oejw.WebSocketConnectionRFC645 5:Text message too large > 32768 chars for ….

Is this expected? The same messages work when using the native websocket in Chrome.

Unsuccessful Handshake IONIC app with websocket

Hi,

I have followed your example as described to establish a connection to websocket. Here is the setup, that I have:

Server Side (development):
Tomcat Websocket (javax.websocket v1.1).

Client Side (development):
Ionic v2.0.0
Cordova v6.3.1

When application is tested on web browser (on desktop), it works well with no issues/errors. However, after the application is built and installed on device. It shows error as following:

Android 6.0.1
Immediately on lauch of the app, it hits onerror and shows "isTrusted":true followed by error code 1006.

Android 4.4
image

Looked up logcat, I notice this

[INFO:CONSOLE(162)] "WebSocket connection to 'ws://xx.xx.xx.xx:9090/ondemand/retail-orders/11' failed: Error during WebSocket handshake: Unexpected response code: 403", source: file:///android_asset/www/plugins/cordova-plugin-websocket/www/websocket.js (162)

Appreciate if you could please provide pointer/suggestion to overcome this issue faced.

Thanks in advance,
Vijay

Android 4.4 needs override plugin option set to true

After installing plugin and deployment on device with android 4.4 I am getting following error.

"WebSocket connection to 'ws://xxxxxxxxxxxxx/' failed: Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received", source: file:///android_asset/www/plugins/com.knowledgecode.cordova.websocket/www/websocket.js (169)

To resolve it I need to set override plugin option to true although I would prepare platform implementation.

websocket.onopen is not called

Hi!

I tried to use this plugin since last 2 days with cordova version 3.3.0. But, unfortunately
websocket.open method is not calling somehow. I tested on Android device Samsung Galaxy SDUOS of android version 4.0.4.

Let me to write the code which I have implemented as under where init method is called ondeviceready:

var wsUri = "ws://echo.websocket.org/";

    var output;
    function init() {
    console.log('init');
        output = document.getElementById("output");
        testWebSocket();
    }
    function testWebSocket() {
    console.log('testWebSocket');
        websocket = new WebSocket(wsUri);
        websocket.onopen = function(evt) {
        console.log('in onopen');       
            onOpen(evt)
        };

        websocket.onmessage = function(evt) {
            onMessage(evt)
        };
        websocket.onerror = function(evt) {
            onError(evt)
        };
    }
    function onOpen(evt) {
        writeToScreen("CONNECTED");
        doSend("WebSocket rocks");
    }

    function onMessage(evt) {
       console.log('RESPONSE: ' + evt.data);
        websocket.close();
    }
    function onError(evt) {
        console.log('ERROR:' + evt.data);
    }
    function doSend(message) {   
        websocket.send(message);
    }

Hope this will help you to identify if any mistake is found.

Thanks in advance..!

uninstalling plugin removes android permission INTERNET

At installation of this plugin the permission (s. below) is written into AndroidManifest.xml, removing the plugin it removes it. So far so good.
This is a problem in the situation where the permission was already in AndroidManifest.xml BEFORE this plugin was installed. In this case I expect that the permission is NOT removed removing the plugin, because there can be other plugins which needs this permission.
But maybe this is the problem of cordova/phonegap plugin add/rm mechanism...in this case this issue is here to remind people about this.

AndroidManifest.xml:

Unescape string in SendingTask before sending it to server

SendingTask.java line 58

conn.sendMessage(rawArgs.substring(11, rawArgs.length() - 2));

rawArgs contains JSON.stringifyed string, which escapes some symbols (specifically double quotes)

You should unescape them before sending it to server.

Something like

JSONArray json = new JSONArray(rawArgs);
String str = (String)json.get(0);
conn.sendMessage(str.substring(9, str.length()));

Cordova 3.3.0

How can I use your code on Cordova 3.3.0. It seems that the plugin method is totally different on Cordova 3.0+.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.