activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Daniels <m...@willdaniels.co.uk>
Subject Null pointer exception in AnyProtocolCodec using WebSockets
Date Sat, 12 May 2012 05:26:19 GMT
Hi,

I'm having problems using WebSockets with Apollo 1.3. I get a null pointer 
exception in AnyProtocol.scala at line 115 which looks like it might be caused 
by changes in 1.3 to do with buffer initialisation (git 5862484)[1].

Yet it seems like a big thing to break and I couldn't see any mention of this in 
the issue tracker or elsewhere, so I thought I should ask here in case I just 
missed something or the error looks like a problem with the way I'm using it...

I created a completely default broker instance and wrote some stuff in Python, 
then PHP to test it and all was seeming to work fine. I then took the modified 
stomp-websocket script (for binary packets) from chirino's fork at github[2] and 
wrote some simple javascript to test the websockets:

---
function logMessage(message)
{
	var log = document.getElementById('log');
	var msg = document.createElement('pre');

	msg.appendChild(document.createTextNode(message));
	log.appendChild(msg);
}

function startLog()
{
	var url = 'ws://localhost:61623/';

	logMessage('About to create STOMP client object...');
	var client = Stomp.client(url);

	client.debug = logMessage;

	client.connect('admin', 'password', function () {
		logMessage('Connected to local STOMP server (via WebSockets)');
		client.subscribe('/topic/test', function (frame) { logMessage(frame.body); });
	});
}
---

This works as expected with 1.2 but with 1.3 it never gets the callback from 
client.connect, and I see the following in the Apollo log after setting debug 
log level for apollo-broker:

---
OS     : Linux 3.2.0-24-generic (Ubuntu 12.04 LTS) | console | 
hawtdispatch-DEFAULT-1
JVM    : OpenJDK 64-Bit Server VM 1.6.0_24 (Sun Microsystems Inc.) | console | 
hawtdispatch-DEFAULT-1
Apollo : 1.3 (at: /usr/local/apache-apollo-1.3) | console | hawtdispatch-DEFAULT-1
...
INFO  | Accepting connections at: ws://0.0.0.0:61623/ | console | Apollo Task
...
WARN  | java.lang.NullPointerException | 
org.apache.activemq.apollo.broker.Broker | hawtdispatch-DEFAULT-2
DEBUG | java.lang.NullPointerException | 
org.apache.activemq.apollo.broker.Broker | hawtdispatch-DEFAULT-2
java.lang.NullPointerException
	at 
org.apache.activemq.apollo.broker.protocol.AnyProtocolCodec$$anonfun$read$1.apply(AnyProtocol.scala:115)
	at 
org.apache.activemq.apollo.broker.protocol.AnyProtocolCodec$$anonfun$read$1.apply(AnyProtocol.scala:112)
	at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:34)
	at scala.collection.mutable.ArrayOps.foreach(ArrayOps.scala:38)
	at 
org.apache.activemq.apollo.broker.protocol.AnyProtocolCodec.read(AnyProtocol.scala:112)
	at 
org.apache.activemq.apollo.broker.jetty.WebSocketTransportFactory$WebSocketTransport.drain_inbound(WebSocketTransportFactory.scala:395)
	at 
org.apache.activemq.apollo.broker.jetty.WebSocketTransportFactory$WebSocketTransport$$anonfun$onMessage$1.apply$mcV$sp(WebSocketTransportFactory.scala:326)
	at org.fusesource.hawtdispatch.package$$anon$3.run(hawtdispatch.scala:357)
	at 
org.fusesource.hawtdispatch.internal.SerialDispatchQueue.run(SerialDispatchQueue.java:96)
	at 
org.fusesource.hawtdispatch.internal.SerialDispatchQueue.run(SerialDispatchQueue.java:96)
	at org.fusesource.hawtdispatch.internal.pool.SimpleThread.run(SimpleThread.java:77)
---

I'm thinking whatever changes were made to determine the buffer sizes maybe did 
not account for WebSockets protocol? But both STOMP and WebSockets are 
completely new to me (as is Scala, Maven and even Java since the last 10 years) 
so I'm a bit out of my depth trying to understand it all at once to be sure it's 
not something I've done wrong, much less try to fix this myself. I haven't even 
managed to get Apollo to build from source yet... one problem after another with 
it :(

Any advice about this issue would be much appreciated!

Thanks,
-Will


[1] 
https://github.com/apache/activemq-apollo/commit/5862484bc44c7f46457cb19cf6638bfd3584595b
[2] https://github.com/chirino/stomp-websocket/blob/master/dist/stomp.js

Mime
View raw message