Giter Site home page Giter Site logo

securewebsockets's Introduction

Secure Web Sockets on Android

This project is meant to add working TLS support to the Autobahn WebSocket library as a preliminary step to implementation at work.

The problem being solved was in part switching the Autobahn library off of Java NIO. Java NIO is broken on Android and you must use the classic java sockets. Android Issue 12955

The project comes with an example Android WebSocket Echo client that communicates with WebSocket.org's echo server with or without SSL encryption.

A quick demonstration for Android

1. Launch the emulator 
2. ./gradlew assembleDebug
3. adb install out/production/SecureWebSockets/SecureWebSockets.apk

To disable SSL certificate checks you can tell SSLCertificateSocketFactory to relax its checks:

On development devices, "setprop socket.relaxsslcheck yes" bypasses all SSL certificate and hostname checks for testing purposes. This setting requires root access.

securewebsockets's People

Contributors

kar avatar palmerc 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

Watchers

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

securewebsockets's Issues

Hanging app n slow internet connection

WebSocket Connection implementation with slow internet connection causes app hanging on device otherwise app functioning smooth. Not at all working in emulator after WebSocket Connection implementation. Is there any fix for this ?

Looper.prepare

when starting a connection from android service i got this error :

04-10 13:28:47.954: E/AndroidRuntime(25438): FATAL EXCEPTION: Timer-0
04-10 13:28:47.954: E/AndroidRuntime(25438): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
04-10 13:28:47.954: E/AndroidRuntime(25438): at android.os.Handler.(Handler.java:121)
04-10 13:28:47.954: E/AndroidRuntime(25438): at de.tavendo.autobahn.WebSocketConnection$ThreadHandler.(WebSocketConnection.java:526)
04-10 13:28:47.954: E/AndroidRuntime(25438): at de.tavendo.autobahn.WebSocketConnection.(WebSocketConnection.java:65)
04-10 13:28:47.954: E/AndroidRuntime(25438): at com.taxi.driver.DdpClient.connect(DdpClient.java:151)
04-10 13:28:47.954: E/AndroidRuntime(25438): at com.taxi.driver.DriverService.logMeIn(DriverService.java:728)
04-10 13:28:47.954: E/AndroidRuntime(25438): at com.taxi.driver.DriverService.connectMe(DriverService.java:790)
04-10 13:28:47.954: E/AndroidRuntime(25438): at com.taxi.driver.DriverService$BackgroundTimer.run(DriverService.java:200)
04-10 13:28:47.954: E/AndroidRuntime(25438): at java.util.Timer$TimerImpl.run(Timer.java:284)

if started from the main UI thread ,working great

License

Hi, Can you please add a license to your project please?

Thank you
Keshav

HeartBeat thread will never finish

Disconnecting does not end the heartbeat thread. It runs in a loop checking isConnected() of WebSocketConnection, which looks like this:

return mSocket != null && mSocket.isConnected()

However according to java documentation of java.net.Socket, isConnected() will be true even if the socket is already closed, given it was in connected state before. So, I think, the !isClosed() check should be added to the condition.

Wait() causes main thread to block

When calling any of the public connect() methods from an Activity, these all route to the core connect() method that spawns a SocketThread.

Code like this executes a few times while the connection is being established. If you call connect() from the main thread, and plan on doing subsequent UI updates, this can be problematic.

        synchronized (mSocketThread) {
            try {
                mSocketThread.wait();
            } catch (InterruptedException e) {
            }
        }

This causes the main thread to block for long periods in certain situations, such as a connection taking a long time to establish. This is not ideal in situations where the UI needs to show a status of the connection. With a little refactoring, I think these waits can probably be removed to fix this.

Force close if App is disconnected to internet

Hi,
First of all thank you for Secured WebSockets Project. It is really helpful. I found one issue with this project.

After connection opened, turn of WIFI. It tries to reconnect the app to WebSockets using scheduleReconnect() method and in method mSocket returns Null thats why app crashes with NullPointerException.

Just added this code to scheduleReconnect() method to avoid crash

if(mSocket==null)
return true;

Can you suggest any better solution or is this fine ?

Thanks,
Punit

WSS Websocket

I am trying to use the lib with wss but i always received "Server error 403 (FORBIDDEN).
Where can i get to understand where is the problem.
Help me, please.

Problem with reconnect

Hi,

I've called the reconnect function in onClose event. When I made changes in my socket server (NodeJS) and restarts the server, I can get the onClose event fired and the reconnect function starts.

But the problem is I'm not able to establish the connection. I got no response for the line outputStream = mSocket.getOutputStream() in WebSocketWriter.java

For the first time connection, I get some response for the same. But when using the reconnect, there is no response. Can you please check?

Reconnect behaviour

After losing the connection, if the first automatic reconnection attempt fails then it doesn't try to reconnect in future. Is this an intentional behaviour?

Headers?

I am trying to use the lib but i can't find a way to pass headers on the connect() method. The Autobahn lib itself does have this feature.

There is any workaround?

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.