Skip to main content

Bad packet magic number when creating connection to JMS broker

1 reply [Last post]
Joined: 2008-03-11

Hi all,

I have a problem when connecting to the JMS broker of my Glassfish. I wrote a simple test client:

package testing.jms.mqtcp;

import javax.jms.Connection;
import javax.jms.JMSException;

import com.sun.messaging.ConnectionConfiguration;
import com.sun.messaging.ConnectionFactory;

public class ConnectionFactoryViaMQTCP {

public static void main( String[] args ) {

final ConnectionFactory sunConnectionFactory = new ConnectionFactory();
try {
//sunConnectionFactory.setProperty( ConnectionConfiguration.imqAddressList, "mqtcp://localhost:10076/jms/" );
sunConnectionFactory.setProperty( ConnectionConfiguration.imqAddressList, "mq://localhost:10076/" );
Connection connection = sunConnectionFactory.createConnection();

} catch ( JMSException e ) {


The code above executes fine. However, when I want to make a connection using "mqtcp://localhost:10076/jms/" it gives the following error message:

WARNING: [I500]: Caught JVM Exception: Bad packet magic number: 825241888. Expecting: 469754818
com.sun.messaging.jms.JMSException: [C4000]: Packet acknowledge failed. user=guest, broker=localhost:10076
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.writePacketWithAck(
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.writePacketWithReply2(
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.hello(
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.hello(
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.hello(
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.openConnection(
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.init(
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.(
at com.sun.messaging.jmq.jmsclient.UnifiedConnectionImpl.(
at com.sun.messaging.BasicConnectionFactory.createConnection(
at com.sun.messaging.BasicConnectionFactory.createConnection(
at testing.jms.mqtcp.ConnectionFactoryViaMQTCP.main(

I know that the expected magic number is from the class ReadOnlyPacket. But I don't know where the other magic number is from.
I use Glassfish V2UR2.
Neither in the Glassfish nor in the IMQ log file I can see connection attempts when using the mqtcp connection, so maybe the URL is wrong at all but I found examples for this URL on the net.

Does anyone know how to correct this error?
And apart from that. If I want to make a connection via the internet to a JMS broker should I then use the mqtcp:// connection or is mq:// also fine?

Thanks in advance,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-09-10

In case anyone looks at this old posting under similar situation

"mqtcp://localhost:10076/jms/" is to talk to the broker's 'jms' service directly on port 10076. Since port 10076 runs the broker portmapper service (as indicated by 'mq://localhost:10076/' works fine), hence the StreamCorruptedException.