users@grizzly.java.net

Re: does Grizzly UDPConnector support this case

From: Survivant 00 <survivant00_at_gmail.com>
Date: Mon, 4 May 2009 08:37:13 -0400

that wierd.. the server never received the message sent by grizzly, but the
server received the message sent from my other code.


any idea ?

bytes sent by grizzly

0000 01 00 5e 7f ff fa 00 15 58 c9 60 ea 08 00 45 00 ..^.....X.`...E.
0010 00 81 77 77 00 00 01 11 9f e2 8e e1 23 37 ef ff ..ww........#7..
0020 ff fa 06 2c 07 6c 00 6d 52 65 4d 2d 53 45 41 52 ...,.l.mReM-SEAR
0030 43 48 20 2a 20 48 54 54 50 2f 31 2e 31 0d 0a 48 CH * HTTP/1.1..H
0040 4f 53 54 3a 20 32 33 39 2e 32 35 35 2e 32 35 35 OST: 239.255.255
0050 2e 32 35 30 3a 31 39 30 30 0d 0a 4d 41 4e 3a 20 .250:1900..MAN:
0060 22 73 73 64 70 3a 64 69 73 63 6f 76 65 72 22 0d "ssdp:discover".
0070 0a 4d 58 3a 20 33 0d 0a 53 54 3a 20 75 70 6e 70 .MX: 3..ST: upnp
0080 3a 72 6f 6f 74 64 65 76 69 63 65 0d 0a 0d 0a :rootdevice....

M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 3
ST: upnp:rootdevice


bytes sent by my other java class

0000 01 00 5e 7f ff fa 00 15 58 c9 60 ea 08 00 45 00 ..^.....X.`...E.
0010 00 81 86 da 00 00 01 11 90 7f 8e e1 23 37 ef ff ............#7..
0020 ff fa 06 32 07 6c 00 6d 52 5f 4d 2d 53 45 41 52 ...2.l.mR_M-SEAR
0030 43 48 20 2a 20 48 54 54 50 2f 31 2e 31 0d 0a 48 CH * HTTP/1.1..H
0040 4f 53 54 3a 20 32 33 39 2e 32 35 35 2e 32 35 35 OST: 239.255.255
0050 2e 32 35 30 3a 31 39 30 30 0d 0a 4d 41 4e 3a 20 .250:1900..MAN:
0060 22 73 73 64 70 3a 64 69 73 63 6f 76 65 72 22 0d "ssdp:discover".
0070 0a 4d 58 3a 20 33 0d 0a 53 54 3a 20 75 70 6e 70 .MX: 3..ST: upnp
0080 3a 72 6f 6f 74 64 65 76 69 63 65 0d 0a 0d 0a :rootdevice....

M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 3
ST: upnp:rootdevice






2009/5/4 Oleksiy Stashok <Oleksiy.Stashok_at_sun.com>

> Hi,
> I don't see any problems with code.
> Can you pls. check, if message you sent, is got received by server?
>
> Thanks.
>
> WBR,
> Alexey.
>
>
> On May 3, 2009, at 14:54 , Survivant 00 wrote:
>
> Hello. I tried for the first time UDP with Grizzly, but my test failed. I
> need to know if what I'm doing is supported in Grizzly.
>
>
> I'm sending a UDP and I'm waiting for the response. Here a testcase that
> works
>
> DatagramSocket ssdpUniSock = new DatagramSocket(null);
>
> // on va envoyer un M-SEARCH
> StringBuffer sb = new StringBuffer();
>
> sb.append("M-SEARCH * HTTP/1.1").append("\r\n");
> sb.append("HOST: 239.255.255.250:1900").append("\r\n");
> sb.append("MAN: \"ssdp:discover\"").append("\r\n");
> sb.append("MX: 3").append("\r\n");
> sb.append("ST: upnp:rootdevice").append("\r\n");
> sb.append("\r\n");
>
> String msg = sb.toString();
>
> InetAddress inetAddr = InetAddress.getByName("239.255.255.250");
>
> DatagramPacket dgmPacket = new DatagramPacket(msg.getBytes(),
> msg.length(), inetAddr, 1900);
>
> ssdpUniSock.send(dgmPacket);
>
> // wait for the answer
> byte ssdvRecvBuf[] = new byte[1024];
> DatagramPacket dgmPacket2 = new DatagramPacket(ssdvRecvBuf, 1024);
>
> ssdpUniSock.receive(dgmPacket2);
>
> int packetLen = dgmPacket2.getLength();
> String packetData = new String(dgmPacket2.getData(), 0, packetLen);
>
> System.out.println(packetData);
>
> ssdpUniSock.close();
>
>
>
> I try with Grizzly but I never saw an answer. I saw my message sent with
> Wireshark.. but no answers.
>
> I put debug on all the methods of ProtocolChainCallbackHandler, but I only
> see the message for "On Connect..."
>
>
> I suppose the Grizzly is waiting on the same port that the client sent the
> message right ?
>
>
> here my code for Grizzly test. (GrizzlyClientProtocolChain.java (the
> client)
>
> here the init method.
>
> public void init() {
>
> f_tg = new ThreadGroup("Client Threads");
>
> final CountDownLatch started = new CountDownLatch(1);
>
> controller = new Controller();
> UDPSelectorHandler udpSelectorHandler = new
> UDPSelectorHandler(true);
> controller.addSelectorHandler(udpSelectorHandler);
>
> BaseSelectionKeyHandler selectionKeyHandler = new
> BaseSelectionKeyHandler();
>
> // to be notify when a client/server close the connection
> selectionKeyHandler.setConnectionCloseHandler(new
> ConnectionCloseHandler() {
>
> public void locallyClosed(SelectionKey key) {
> if(s_logger.isDebugEnabled()){
> s_logger.debug(key + " is being locally
> cancelled");
> }
> }
>
> public void remotlyClosed(SelectionKey key) {
> if(s_logger.isDebugEnabled()){
> s_logger.debug(key + " is being remotly cancelled
> (connection closed)");
> }
> }
> });
>
> udpSelectorHandler.setSelectionKeyHandler(selectionKeyHandler);
>
> // STATE Listener
> controller.addStateListener(new ControllerStateListenerAdapter() {
>
> public void onException(Throwable e) {
> s_logger.error("Grizzly controller exception:" +
> e.getMessage());
> }
>
> public void onReady() {
> if(s_logger.isDebugEnabled()){
> s_logger.debug("Ready!");
> }
> started.countDown();
> }
>
> });
>
>
> // the protocol chain
> EchoQueryProtocolFilter protocolParser = new
> EchoQueryProtocolFilter();
> EchoQueryManagerFilter echoManagerFilter = new
> EchoQueryManagerFilter(this);
>
> final ProtocolChain protocolChain = new DefaultProtocolChain();
> protocolChain.addFilter(protocolParser);
> protocolChain.addFilter(echoManagerFilter);
> ((DefaultProtocolChain)
> protocolChain).setContinuousExecution(true);
>
>
> ProtocolChainInstanceHandler pciHandler = new
> DefaultProtocolChainInstanceHandler() {
>
> public boolean offer(ProtocolChain protocolChain) {
> return false;
>
> }
>
> public ProtocolChain poll() {
>
> return protocolChain;
> }
> };
>
> controller.setProtocolChainInstanceHandler(pciHandler);
>
> // start the client
> new Thread(f_tg, controller).start();
>
> try {
> started.await();
> } catch (Exception e) {
> s_logger.error("Timeout in wait" + e.getMessage());
> }
>
> // extra stuff : Queue
> blockingQueue = new LinkedBlockingQueue<QueueItem>();
> queueConsumer = new QueueConsumer(this, blockingQueue);
> new Thread(f_tg, queueConsumer,"QueueConsumer").start();
>
> connector_handler = (UDPConnectorHandler)
> controller.acquireConnectorHandler(Controller.Protocol.UDP);
>
> }
>
> <grizzly_UDP.zip>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>
>
>