Skip to main content

Problems with JxtaServer

4 replies [Last post]
krobinson
Offline
Joined: 2007-06-12
Points: 0

Hi I've been trying to use JxtaServer and JxtaBiDiPipe with little success. I've adapted the JxtBiDiPipe example from the Programmer's manual 2.5

I have two Linux computers on a LAN with multicast enable in the kernel. Both are set up as ADHOC peers. Both use the NetPeerGroup and have the same Ad for the PipeMsg. Firewalls have been disabled.

For the SERVER
I cannot get pas the JxtaServer accept() message. See the SERVERCODE below. I have run another test thread to make sure it does not hog all the processor time and found it works fine. I have used Wireshark to log JXTA messages. I get repeated messages from CLIENT but nothing more. See SERVER MESSAGE below.

For the CLIENT
On the CLIENT it appears to connect but it appears to connect even when the Server is not running. See CLIENTCODE below. It sends through messages, see CLIENT MESSAGE below, but does not get anything back.

Can anyone tell me what I am doing wrong?

SERVER CODE:

jxtaServer()
{
this method starts a thread ConnectionHandlerServer
}

private class ConnectionHandlerServer implements Runnable, PipeMsgListener
{
JxtaBiDiPipe pipe = null;
private final String receipt = "Receipt";
JxtaServerPipe serverPipe = null;

ConnectionHandlerServer(JxtaServerPipe serverPipe) {
this.serverPipe = serverPipe;
}

public void pipeMsgEvent(PipeMsgEvent event) {
Message msg = null;
try {
// grab the message from the event
msg = event.getMessage();
if (msg == null) {
if (Logging.SHOW_FINE && logger.isLoggable(Level.FINE)) {
logger.fine("Received an empty message, returning");
}
return;
}
if (Logging.SHOW_FINE && logger.isLoggable(Level.FINE)) {
logger.fine("Received a response");
}
// get the message element named SenderMessage
MessageElement msgElement = msg.getMessageElement(SenderMessage, SenderMessage);

// Get message
if (msgElement.toString() == null) {
System.out.println("null msg received");
} else {
System.out.println("Got Message :" + msgElement.toString());
}
} catch (Exception e) {
if (Logging.SHOW_FINE && logger.isLoggable(Level.FINE)) {
logger.fine(e.toString());
}
}

synchronized (receipt) {
receipt.notify();
}
}

public void sendResponseUponRequest()
{
try {
synchronized (receipt) {
receipt.wait();
}
Message msg = new Message();
String data = "Okay, here is the ball.";
msg.addMessageElement(SenderMessage,
new StringMessageElement(SenderMessage,
data,
null));
System.out.print("Sending :" + data);
pipe.sendMessage(msg);

} catch (Exception e) {
e.printStackTrace();
}
}

public void run() {
try {
System.out.println("before serverPipe.accept");
pipe = serverPipe.accept();
pipe.setMessageListener(this);
System.out.println("after serverPipe.accept");
sendResponseUponRequest();
pipe.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

SERVER MESSAGE:
No. Time Source Destination Protocol Info
34 51.557511 192.168.1.101 224.0.1.85 JXTA Message, 192.168.1.101:1234 -> 224.0.1.85:1234

Frame 34 (1481 bytes on wire, 1481 bytes captured)
Arrival Time: Sep 23, 2007 01:13:44.784170000
[Time delta from previous packet: 0.009586000 seconds]
[Time since reference or first frame: 51.557511000 seconds]
Frame Number: 34
Packet Length: 1481 bytes
Capture Length: 1481 bytes
[Frame is marked: False]
[Protocols in frame: sll:ip:udp:jxta:jxta.message:xml:xml:data-text-lines:data-text-lines:data-text-lines]
[Coloring Rule Name: Low TTL]
[Coloring Rule String: ip.ttl < 5]
Linux cooked capture
Packet type: Multicast (2)
Link-layer address type: 1
Link-layer address length: 6
Source: Asiarock_10:db:51 (00:19:66:10:db:51)
Protocol: IP (0x0800)
Internet Protocol, Src: 192.168.1.101 (192.168.1.101), Dst: 224.0.1.85 (224.0.1.85)
Version: 4
Header length: 20 bytes
Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)
0000 00.. = Differentiated Services Codepoint: Default (0x00)
.... ..0. = ECN-Capable Transport (ECT): 0
.... ...0 = ECN-CE: 0
Total Length: 1465
Identification: 0x0000 (0)
Flags: 0x04 (Don't Fragment)
0... = Reserved bit: Not set
.1.. = Don't fragment: Set
..0. = More fragments: Not set
Fragment offset: 0
Time to live: 1
Protocol: UDP (0x11)
Header checksum: 0xd0d1 [correct]
[Good: True]
[Bad : False]
Source: 192.168.1.101 (192.168.1.101)
Destination: 224.0.1.85 (224.0.1.85)
User Datagram Protocol, Src Port: 1234 (1234), Dst Port: 1234 (1234)
Source port: 1234 (1234)
Destination port: 1234 (1234)
Length: 1445
Checksum: 0x9132 [correct]
JXTA Message Framing Headers
Header "content-type"
Name: content-type
Value Length: 22
Value: 6170706C69636174696F6E2F782D6A7874612D6D7367
Header "content-length"
Name: content-length
Value Length: 8
Value: 000000000000055A
Header
Name:
JXTA
JXTA UDP Message
Signature: JXTA
JXTA Message Framing Headers
Header "content-type"
Name: content-type
Value Length: 22
Value: 6170706C69636174696F6E2F782D6A7874612D6D7367
Header "content-length"
Name: content-length
Value Length: 8
Value: 000000000000055A
Header
Name:
JXTA Message, 192.168.1.101:1234 -> 224.0.1.85:1234
Signature: jxmg
[Source: 192.168.1.101:1234]
[Destination: 224.0.1.85:1234]
Version: 0
Namespace Count: 0
Element Count: 5
JXTA Message Element "jxta-NetGroupSrdi"
Signature: jxel
Namespace ID: 1 (jxta)
Flags: 0x01
..1 = hasType: Set
.0. = hasEncoding: Not set
0.. = hasSignature: Not set
Element Name: jxta-NetGroupSrdi
Element Type: application/gzip
Element Content Length: 347 -> (647 uncompressed)
eXtensible Markup Language
<?xml
version="1.0"
encoding="UTF-8"
?>

JxtaPipeResolver\n\t

<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE jxta:GenSRDI>\n<jxta:GenSRDI xmlns:jxta="http://jxta.org">\n\t<PID>\n\t\turn:jxta:uuid-59616261646162614E5047205032503321CFD7D7A6C448B889A8FECF541D406503\n\t</PID>\n\t<PKe

JXTA Message Element "RendezVousPropagatejxta-NetGroup"
Signature: jxel
Namespace ID: 1 (jxta)
Flags: 0x01
..1 = hasType: Set
.0. = hasEncoding: Not set
0.. = hasSignature: Not set
Element Name: RendezVousPropagatejxta-NetGroup
Element Type: text/xml;charset=UTF-8
Element Content Length: 478
eXtensible Markup Language
<?xml
version="1.0"
encoding="UTF-8"
?>

00000181-0000-1000-82bb-c6b646270738

urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000205

jxta-NetGroupSrdi

2

urn:jxta:uuid-59616261646162614E5047205032503321CFD7D7A6C448B889A8FECF541D406503

JXTA Message Element "EndpointHeaderSrcPeer"
Signature: jxel
Namespace ID: 1 (jxta)
Flags: 0x01
..1 = hasType: Set
.0. = hasEncoding: Not set
0.. = hasSignature: Not set
Element Name: EndpointHeaderSrcPeer
Element Type: text/plain;charset=UTF-8
Element Content Length: 80
Line-based text data: text/plain
urn:jxta:uuid-59616261646162614E5047205032503321CFD7D7A6C448B889A8FECF541D406503
JXTA Message Element "EndpointSourceAddress"
Signature: jxel
Namespace ID: 1 (jxta)
Flags: 0x01
..1 = hasType: Set
.0. = hasEncoding: Not set
0.. = hasSignature: Not set
Element Name: EndpointSourceAddress
Element Type: text/plain;charset=UTF-8
Element Content Length: 78
Line-based text data: text/plain
jxta://uuid-59616261646162614E5047205032503321CFD7D7A6C448B889A8FECF541D406503
JXTA Message Element "EndpointDestinationAddress"
Signature: jxel
Namespace ID: 1 (jxta)
Flags: 0x01
..1 = hasType: Set
.0. = hasEncoding: Not set
0.. = hasSignature: Not set
Element Name: EndpointDestinationAddress
Element Type: text/plain;charset=UTF-8
Element Content Length: 81
Line-based text data: text/plain
mcast://224.0.1.85:1234/EndpointService:jxta-NetGroup/JxtaPropagate/jxta-NetGroup

CLIENT CODE:
public void jxtaClient() throws IOException
{
JxtaBiDiPipe clientBiDiPipe = null;
try {
clientBiDiPipe = new JxtaBiDiPipe();
clientBiDiPipe.setReliable(false);

System.out.println("Attempting to establish a connection");
try {
clientBiDiPipe.connect(peerGroup,
getPipeAdvertisement(),
Integer.parseInt(timeoutClientPipe));
// at this point we need to keep references around
// until data exchange is complete

} catch (IOException e) {
System.out.println("got io exception");
e.printStackTrace();
}

if (clientBiDiPipe.isBound()) {
System.out.println("JxtaBidiPipe connected, sending ");
clientBiDiPipe.sendMessage(wrapMessage("Kick the ball to me"));
System.out.print("Sending : Kick ball to me");
String receivedMsg = unwrapMessage(clientBiDiPipe.getMessage(0));
System.out.print("Received : " + receivedMsg);
} else {
System.out.println("JxtaBidiPipe not connected");
}

} catch (Exception e) {
e.printStackTrace();

} finally {
if (clientBiDiPipe.isBound()) {
clientBiDiPipe.close();
}
}
}

CLIENT MESSAGE:
No. Time Source Destination Protocol Info
34 51.557511 192.168.1.101 224.0.1.85 JXTA Message, 192.168.1.101:1234 -> 224.0.1.85:1234

Frame 34 (1481 bytes on wire, 1481 bytes captured)
Arrival Time: Sep 23, 2007 01:13:44.784170000
[Time delta from previous packet: 0.009586000 seconds]
[Time since reference or first frame: 51.557511000 seconds]
Frame Number: 34
Packet Length: 1481 bytes
Capture Length: 1481 bytes
[Frame is marked: False]
[Protocols in frame: sll:ip:udp:jxta:jxta.message:xml:xml:data-text-lines:data-text-lines:data-text-lines]
[Coloring Rule Name: Low TTL]
[Coloring Rule String: ip.ttl < 5]
Linux cooked capture
Packet type: Multicast (2)
Link-layer address type: 1
Link-layer address length: 6
Source: Asiarock_10:db:51 (00:19:66:10:db:51)
Protocol: IP (0x0800)
Internet Protocol, Src: 192.168.1.101 (192.168.1.101), Dst: 224.0.1.85 (224.0.1.85)
Version: 4
Header length: 20 bytes
Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)
0000 00.. = Differentiated Services Codepoint: Default (0x00)
.... ..0. = ECN-Capable Transport (ECT): 0
.... ...0 = ECN-CE: 0
Total Length: 1465
Identification: 0x0000 (0)
Flags: 0x04 (Don't Fragment)
0... = Reserved bit: Not set
.1.. = Don't fragment: Set
..0. = More fragments: Not set
Fragment offset: 0
Time to live: 1
Protocol: UDP (0x11)
Header checksum: 0xd0d1 [correct]
[Good: True]
[Bad : False]
Source: 192.168.1.101 (192.168.1.101)
Destination: 224.0.1.85 (224.0.1.85)
User Datagram Protocol, Src Port: 1234 (1234), Dst Port: 1234 (1234)
Source port: 1234 (1234)
Destination port: 1234 (1234)
Length: 1445
Checksum: 0x9132 [correct]
JXTA Message Framing Headers
Header "content-type"
Name: content-type
Value Length: 22
Value: 6170706C69636174696F6E2F782D6A7874612D6D7367
Header "content-length"
Name: content-length
Value Length: 8
Value: 000000000000055A
Header
Name:
JXTA
JXTA UDP Message
Signature: JXTA
JXTA Message Framing Headers
Header "content-type"
Name: content-type
Value Length: 22
Value: 6170706C69636174696F6E2F782D6A7874612D6D7367
Header "content-length"
Name: content-length
Value Length: 8
Value: 000000000000055A
Header
Name:
JXTA Message, 192.168.1.101:1234 -> 224.0.1.85:1234
Signature: jxmg
[Source: 192.168.1.101:1234]
[Destination: 224.0.1.85:1234]
Version: 0
Namespace Count: 0
Element Count: 5
JXTA Message Element "jxta-NetGroupSrdi"
Signature: jxel
Namespace ID: 1 (jxta)
Flags: 0x01
..1 = hasType: Set
.0. = hasEncoding: Not set
0.. = hasSignature: Not set
Element Name: jxta-NetGroupSrdi
Element Type: application/gzip
Element Content Length: 347 -> (647 uncompressed)
eXtensible Markup Language
<?xml
version="1.0"
encoding="UTF-8"
?>

JxtaPipeResolver\n\t

<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE jxta:GenSRDI>\n<jxta:GenSRDI xmlns:jxta="http://jxta.org">\n\t<PID>\n\t\turn:jxta:uuid-59616261646162614E5047205032503321CFD7D7A6C448B889A8FECF541D406503\n\t</PID>\n\t<PKe

JXTA Message Element "RendezVousPropagatejxta-NetGroup"
Signature: jxel
Namespace ID: 1 (jxta)
Flags: 0x01
..1 = hasType: Set
.0. = hasEncoding: Not set
0.. = hasSignature: Not set
Element Name: RendezVousPropagatejxta-NetGroup
Element Type: text/xml;charset=UTF-8
Element Content Length: 478
eXtensible Markup Language
<?xml
version="1.0"
encoding="UTF-8"
?>

00000181-0000-1000-82bb-c6b646270738

urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000205

jxta-NetGroupSrdi

2

urn:jxta:uuid-59616261646162614E5047205032503321CFD7D7A6C448B889A8FECF541D406503

JXTA Message Element "EndpointHeaderSrcPeer"
Signature: jxel
Namespace ID: 1 (jxta)
Flags: 0x01
..1 = hasType: Set
.0. = hasEncoding: Not set
0.. = hasSignature: Not set
Element Name: EndpointHeaderSrcPeer
Element Type: text/plain;charset=UTF-8
Element Content Length: 80
Line-based text data: text/plain
urn:jxta:uuid-59616261646162614E5047205032503321CFD7D7A6C448B889A8FECF541D406503
JXTA Message Element "EndpointSourceAddress"
Signature: jxel
Namespace ID: 1 (jxta)
Flags: 0x01
..1 = hasType: Set
.0. = hasEncoding: Not set
0.. = hasSignature: Not set
Element Name: EndpointSourceAddress
Element Type: text/plain;charset=UTF-8
Element Content Length: 78
Line-based text data: text/plain
jxta://uuid-59616261646162614E5047205032503321CFD7D7A6C448B889A8FECF541D406503
JXTA Message Element "EndpointDestinationAddress"
Signature: jxel
Namespace ID: 1 (jxta)
Flags: 0x01
..1 = hasType: Set
.0. = hasEncoding: Not set
0.. = hasSignature: Not set
Element Name: EndpointDestinationAddress
Element Type: text/plain;charset=UTF-8
Element Content Length: 81
Line-based text data: text/plain
mcast://224.0.1.85:1234/EndpointService:jxta-NetGroup/JxtaPropagate/jxta-NetGroup

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
krobinson
Offline
Joined: 2007-06-12
Points: 0

Hi Everyone,
I've discovered if I do not persist the Config, if it is created afresh each time the application is run, I can send and receive message in JXTA. (I have tried this with multicast not JxtaServer but the principle should be the same). I will have to look at the config to see what is different between the two JXTA nodes.

hamada
Offline
Joined: 2003-06-12
Points: 0

couple of things to check

- ensure that getPipeAdvertisement() always generates the same pipe ID, and used by both the server and client.
- The run method terminates after the first connection, not sure if it is the intended effect

and finally post your findings regarding the configuration diffs

krobinson
Offline
Joined: 2007-06-12
Points: 0

Thank you for the quick reply.
Sorry for not including all the code. Elsewhere it has a "new JxtaServerPipe()".

regards,
ken.

asghar
Offline
Joined: 2005-07-26
Points: 0

Hi,
It seems you didn’t instantiate the JxtaServerPipe!
What happens, if you modify the code as following?

SERVER CODE:

jxtaServer()
{
this method starts a thread ConnectionHandlerServer
}

private class ConnectionHandlerServer implements Runnable, PipeMsgListener
{
JxtaBiDiPipe pipe = null;
private final String receipt = "Receipt";
JxtaServerPipe serverPipe = [b]new JxtaServerPipe ();[/b]

ConnectionHandlerServer(JxtaServerPipe serverPipe) {
this.serverPipe = serverPipe;
}
…….