users@tyrus.java.net

Secure web socket in Android

From: Mitt W <weiwei1076_at_gmail.com>
Date: Tue, 05 May 2015 02:48:58 -0700 (PDT)

Hi,


I’ve faced an exception when securing web socket with Tyrus. In iOS, ws and was work just fine, however ws works, wss don’t work in Android. The error info is pasted below:


W/DefaultFilterChain﹕ GRIZZLY0013: Exception during FilterChain execution
    java.lang.IllegalArgumentException: one of the src == null
            at com.android.org.conscrypt.OpenSSLEngineImpl.wrap(OpenSSLEngineImpl.java:525)
            at org.glassfish.grizzly.ssl.SSLConnectionContext.wrap(SSLConnectionContext.java:286)
            at org.glassfish.grizzly.ssl.SSLConnectionContext.wrapAll(SSLConnectionContext.java:227)
            at org.glassfish.grizzly.ssl.SSLBaseFilter.wrapAll(SSLBaseFilter.java:405)
            at org.glassfish.grizzly.ssl.SSLBaseFilter.handleWrite(SSLBaseFilter.java:320)
            at org.glassfish.grizzly.ssl.SSLFilter.accurateWrite(SSLFilter.java:263)
            at org.glassfish.grizzly.ssl.SSLFilter.handleWrite(SSLFilter.java:143)
            at org.glassfish.grizzly.filterchain.ExecutorResolver$8.execute(ExecutorResolver.java:111)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:291)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:209)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:137)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:115)
            at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
            at org.glassfish.grizzly.filterchain.FilterChainContext$1.run(FilterChainContext.java:191)
            at org.glassfish.grizzly.filterchain.FilterChainContext.resume(FilterChainContext.java:215)
            at org.glassfish.grizzly.ssl.SSLFilter$SSLHandshakeContext.completed(SSLFilter.java:383)
            at org.glassfish.grizzly.ssl.SSLFilter.notifyHandshakeComplete(SSLFilter.java:278)
            at org.glassfish.grizzly.ssl.SSLBaseFilter.handleRead(SSLBaseFilter.java:275)
            at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:291)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:209)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:137)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:115)
            at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
            at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:550)
            at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
            at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
            at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
            at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
            at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
            at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
            at java.lang.Thread.run(Thread.java:818)
05-05 17:42:00.416  25893-26589/com.example.AndroidClientTest W/System.err﹕ javax.websocket.DeploymentException: Handshake response not received.
05-05 17:42:00.417  25893-26589/com.example.AndroidClientTest W/System.err﹕ at org.glassfish.tyrus.client.ClientManager$1$1.run(ClientManager.java:490)
05-05 17:42:00.417  25893-26589/com.example.AndroidClientTest W/System.err﹕ at org.glassfish.tyrus.client.ClientManager$1.run(ClientManager.java:502)
05-05 17:42:00.417  25893-26589/com.example.AndroidClientTest W/System.err﹕ at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
05-05 17:42:00.418  25893-26589/com.example.AndroidClientTest W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
05-05 17:42:00.418  25893-26589/com.example.AndroidClientTest W/System.err﹕ at org.glassfish.tyrus.client.ClientManager$SameThreadExecutorService.execute(ClientManager.java:654)
05-05 17:42:00.418  25893-26589/com.example.AndroidClientTest W/System.err﹕ at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:81)
05-05 17:42:00.418  25893-26589/com.example.AndroidClientTest W/System.err﹕ at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:359)
05-05 17:42:00.418  25893-26589/com.example.AndroidClientTest W/System.err﹕ at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:231)
05-05 17:42:00.418  25893-26589/com.example.AndroidClientTest W/System.err﹕ at com.example.AndroidClientTest.MyActivity$1$1.doInBackground(MyActivity.java:51)
05-05 17:42:00.419  25893-26589/com.example.AndroidClientTest W/System.err﹕ at com.example.AndroidClientTest.MyActivity$1$1.doInBackground(MyActivity.java:44)
05-05 17:42:00.419  25893-26589/com.example.AndroidClientTest W/System.err﹕ at android.os.AsyncTask$2.call(AsyncTask.java:292)
05-05 17:42:00.419  25893-26589/com.example.AndroidClientTest W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
05-05 17:42:00.419  25893-26589/com.example.AndroidClientTest W/System.err﹕ at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
05-05 17:42:00.419  25893-26589/com.example.AndroidClientTest W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
05-05 17:42:00.420  25893-26589/com.example.AndroidClientTest W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
05-05 17:42:00.420  25893-26589/com.example.AndroidClientTest W/System.err﹕ at java.lang.Thread.run(Thread.java:818)


Best
Wei Wei