users@tyrus.java.net

Re: Few problems/doubts about a first websocket client app in android using tyrus

From: Salatiel Filho <salatiel.filho_at_gmail.com>
Date: Sun, 15 Jun 2014 10:43:11 -0300

Hi Pavel, your example works , thanks !
A few times though i keep getting that
GRIZZLY0013: Exception during FilterChain execution
java.lang.IllegalStateException: java.lang.NumberFormatException

on the server i am connecting to. (Not the echo one)

The problem is that when i get this error no callback is done to
onClose , onOpen , reconnectHandler.onDisconnect,
reconnectHandler.onConnectFailure , so i don't know how to detect this
event. Any ideas how to detect this error ?

Thanks !


[]'s
Salatiel


On Sat, Jun 14, 2014 at 7:29 AM, Pavel Bucek <pavel.bucek_at_oracle.com> wrote:
> Ok, so..
>
> forget about jdk client - it seems like it does not work on Android yet
> (maybe it does not completely implement JAVA 7 AIO API.. not sure, haven't
> investigated that much).
>
> I trued the original jar: tyrus-standalone-client-1.7-SNAPSHOT.jar
>
> (grizzly based client, all dependencies packed into single jar; you don't
> need to use snapshot, 1.6 should work as well).
>
>
> and with code as simple asi this one:
>
> button.setOnClickListener(new View.OnClickListener() {
> @Override
> public void onClick(View view) {
>
> Log.i("TYRUS-TEST", "### 0 Button.onClick");
>
> final AsyncTask<Void, Void, Void> asyncTask = new
> AsyncTask<Void, Void, Void>() {
> @Override
> protected Void doInBackground(Void... voids) {
> try {
> final ClientManager client =
> ClientManager.createClient();
>
> Log.i("TYRUS-TEST", "### 1
> AsyncTask.doInBackground");
> client.connectToServer(new Endpoint() {
> @Override
> public void onOpen(Session session,
> EndpointConfig EndpointConfig) {
>
> try {
> session.addMessageHandler(new MessageHandler.Whole<String>() {
> @Override
> public void onMessage(String
> message) {
> Log.i("TYRUS-TEST", "### 3 Tyrus Client onMessage: " + message);
> }
> });
>
> Log.i("TYRUS-TEST", "### 2 Tyrus Client onOpen");
> session.getBasicRemote().sendText("Do or do not, there is no try.");
> } catch (IOException e) {
> // do nothing
> }
> }
> },
> ClientEndpointConfig.Builder.create().build(),
> URI.create("ws://echo.websocket.org"));
>
> } catch (DeploymentException e) {
> e.printStackTrace();
> } catch (IOException e) {
> e.printStackTrace();
> }
> return null;
> }
> };
>
> asyncTask.execute();
> }
> });
>
> I was able to reach echo.wesocket.org (from emulator, but it should work
> with your device as well).
>
> my log output:
>
> 06-14 06:23:59.320 1462-1462/tyrustestapp_2.app I/TYRUS-TEST﹕ ### 0
> Button.onClick
> 06-14 06:24:01.400 1462-1481/tyrustestapp_2.app I/dalvikvm﹕ Failed
> resolving Lorg/glassfish/tyrus/core/OsgiRegistry; interface 2569
> 'Lorg/osgi/framework/SynchronousBundleListener;'
> 06-14 06:24:01.400 1462-1481/tyrustestapp_2.app W/dalvikvm﹕ Link of class
> 'Lorg/glassfish/tyrus/core/OsgiRegistry;' failed
> 06-14 06:24:01.440 1462-1481/tyrustestapp_2.app I/dalvikvm﹕ Could not
> find method org.glassfish.tyrus.core.OsgiRegistry.getInstance, referenced
> from method
> org.glassfish.tyrus.core.ReflectionHelper.getOsgiRegistryInstance
> 06-14 06:24:01.440 1462-1481/tyrustestapp_2.app W/dalvikvm﹕ VFY: unable
> to resolve static method 19186:
> Lorg/glassfish/tyrus/core/OsgiRegistry;.getInstance
> ()Lorg/glassfish/tyrus/core/OsgiRegistry;
> 06-14 06:24:01.440 1462-1481/tyrustestapp_2.app D/dalvikvm﹕ VFY:
> replacing opcode 0x71 at 0x0008
> 06-14 06:24:01.500 1462-1481/tyrustestapp_2.app I/dalvikvm﹕ Failed
> resolving Lorg/glassfish/tyrus/core/OsgiRegistry; interface 2569
> 'Lorg/osgi/framework/SynchronousBundleListener;'
> 06-14 06:24:01.510 1462-1481/tyrustestapp_2.app W/dalvikvm﹕ Link of class
> 'Lorg/glassfish/tyrus/core/OsgiRegistry;' failed
> 06-14 06:24:01.510 1462-1481/tyrustestapp_2.app W/dalvikvm﹕ VFY: unable
> to find class referenced in signature
> (Lorg/glassfish/tyrus/core/OsgiRegistry;)
> 06-14 06:24:01.650 1462-1481/tyrustestapp_2.app I/TYRUS-TEST﹕ ### 1
> AsyncTask.doInBackground
> 06-14 06:24:02.640 1462-1481/tyrustestapp_2.app D/dalvikvm﹕ GC_FOR_ALLOC
> freed 193K, 8% free 3192K/3452K, paused 159ms, total 160ms
> 06-14 06:24:05.580 1462-1481/tyrustestapp_2.app D/dalvikvm﹕ GC_FOR_ALLOC
> freed 501K, 16% free 3204K/3772K, paused 57ms, total 58ms
> 06-14 06:24:06.200 1462-1481/tyrustestapp_2.app D/dalvikvm﹕ GC_FOR_ALLOC
> freed 135K, 10% free 3413K/3772K, paused 48ms, total 48ms
> 06-14 06:24:06.310 1462-1481/tyrustestapp_2.app D/dalvikvm﹕ GC_FOR_ALLOC
> freed 133K, 12% free 3466K/3936K, paused 57ms, total 57ms
> 06-14 06:24:06.440 1462-1481/tyrustestapp_2.app D/dalvikvm﹕ GC_FOR_ALLOC
> freed 145K, 13% free 3534K/4036K, paused 56ms, total 56ms
> 06-14 06:24:07.810 1462-1481/tyrustestapp_2.app D/dalvikvm﹕ GC_FOR_ALLOC
> freed 278K, 9% free 3767K/4112K, paused 42ms, total 42ms
> 06-14 06:24:08.520 1462-1481/tyrustestapp_2.app D/dalvikvm﹕ GC_FOR_ALLOC
> freed 412K, 12% free 3868K/4348K, paused 44ms, total 47ms
> 06-14 06:24:09.490 1462-1486/tyrustestapp_2.app D/dalvikvm﹕ GC_FOR_ALLOC
> freed 207K, 8% free 4118K/4448K, paused 41ms, total 41ms
> 06-14 06:24:09.910 1462-1485/tyrustestapp_2.app I/TYRUS-TEST﹕ ### 2 Tyrus
> Client onOpen
> 06-14 06:24:10.420 1462-1486/tyrustestapp_2.app I/TYRUS-TEST﹕ ### 3 Tyrus
> Client onMessage: Do or do not, there is no try.
> 06-14 06:26:11.700 1462-1485/tyrustestapp_2.app D/dalvikvm﹕ GC_FOR_ALLOC
> freed 417K, 11% free 4197K/4696K, paused 33ms, total 41ms
>
> Hope it helps,
> Pavel
>
>
>
>
> On 13/06/14 12:58, Salatiel Filho wrote:
>>
>> On Fri, Jun 13, 2014 at 7:45 AM, Pavel Bucek <pavel.bucek_at_oracle.com>
>> wrote:
>>>
>>>
>>> ClientManager.createClient("org.glassfish.tyrus.container.jdk.client.JdkClientContainer");
>>
>> Pavel, now i get:
>>
>> W/dalvikvm(7769): Link of class 'Lorg/glassfish/tyrus/core/OsgiRegistry;'
>> failed
>> W/dalvikvm(7769): VFY: unable to resolve static method 6745:
>> Lorg/glassfish/tyrus/core/OsgiRegistry;.getInstance
>> ()Lorg/glassfish/tyrus/core/OsgiRegistry;
>> W/dalvikvm(7769): Link of class 'Lorg/glassfish/tyrus/core/OsgiRegistry;'
>> failed
>> W/dalvikvm(7769): VFY: unable to find class referenced in signature
>> (Lorg/glassfish/tyrus/core/OsgiRegistry;)
>> W/dalvikvm(7769): VFY: unable to find class referenced in signature
>> (Ljava/nio/channels/CompletionHandler;)
>> W/dalvikvm(7769): Link of class
>> 'Lorg/glassfish/tyrus/container/jdk/client/JdkClientContainer$1;'
>> failed
>> E/dalvikvm(7083): Could not find class
>> 'org.glassfish.tyrus.container.jdk.client.JdkClientContainer$1',
>> referenced from method
>> org.glassfish.tyrus.container.jdk.client.JdkClientContainer.connect
>> E/dalvikvm(7083): Could not find class
>> 'org.glassfish.tyrus.container.jdk.client.TransportFilter$3',
>> referenced from method
>> org.glassfish.tyrus.container.jdk.client.TransportFilter.read
>> E/dalvikvm(7083): Could not find class
>> 'org.glassfish.tyrus.container.jdk.client.TransportFilter$1',
>> referenced from method
>> org.glassfish.tyrus.container.jdk.client.TransportFilter.write
>>
>> Thanks for the help !
>>
>>
>> []'s
>> Salatiel
>>
>>
>