Hello Laurent,
I send a very basic application which works fine for me with the current
content of the svn repository.
Here is the console trace I get:
thie...@thierry-laptop:~$ curl -i -X POST -H "Content-Type:
application/json" -d Laurent http://localhost:8182/test/resource
HTTP/1.1 200 The request has succeeded
Accept-Ranges: bytes
Content-Length: 14
Content-Type: */*; charset=ISO-8859-1
Date: Mon, 25 Jan 2010 16:45:33 GMT
Server:
Restlet-Framework/@major-num...@.@minor-number@@release-type@@release-number@
Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
hello Laurent
thie...@thierry-laptop:~$
Could you try it?
Best regards,
THierry Boileau
> Hello everybody,
> I have a problem using Netty connector.
> When I use either curl or rest-client (see
> http://code.google.com/p/rest-client/ )
> for a POST on a resource, it seems to not tell the client that the
> answer has been sent.
> Here, I send using a curl a json
> N:\>curl -i -X POST -H "Content-Type: application/json" -d
> {"mode":"production"} http://localhost:8080/server/mode
> HTTP/1.1 200 The request has succeeded
> Accept-Ranges: bytes
> Content-Location: http://localhost:8080/server/status
> Content-Type: application/json; charset=UTF-8
> Date: Tue, 19 Jan 2010 10:22:32 GMT
> Server: Restlet-Framework/2.0m6
> Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
>
> {"server changed":"production"}
> but the curl command didn't end, I have to send the break signal.
> Same things with rest-client, I see in my log that the request as been
> handled correctly, but nothing appears in the gui,
> and I have to push the stop button.
> I don't have this problem with internal connector or jetty.
> I tried to discover more informations, so using tcp spy I got the following
> *** with jetty *** :
> socket (9344) accepting a connection synchronously without blocking
> socket (9344) accepted a connection on new socket (9268)
> [addr=127.0.0.1:2299]
> socket (9268) specified an event object to be associated with the
> supplied set of network events and enabled its nonblocking mode
> [hEventObject=0, lEvent==0]
> socket (9268) disabled its nonblocking mode
> socket (9268) enabled its nonblocking mode
> socket (9268) set one of its options [level=IPPROTO_TCP, optname=1]
> socket (9268) set one of its options [level=SOL_SOCKET,
> optname=SO_LINGER, l_onoff=1, l_linger=1]
> socket (9268) receiving data synchronously without blocking [len=4096]
> socket (9268) received 217 bytes of data
> POST /server/mode HTTP/1.1
> Content-Length: 28
> Content-Type: application/json; charset=UTF-8
> Host: localhost:8080
> Connection: Keep-Alive
> User-Agent: Apache-HttpClient/4.0-beta2 (java 1.5)
> Expect: 100-Continue
>
> socket (9268) determined its local name [name=127.0.0.1:8080]
> socket (9268) determined its local name [name=127.0.0.1:8080]
> socket (9268) sending data synchronously without blocking [len=25]
> socket (9268) sent 25 bytes of data
> HTTP/1.1 100 Continue
>
> socket (9268) receiving data synchronously without blocking [len=3879]
> socket (9268) received 28 bytes of data (Incomplete last line)
> {
> "mode":"production"
> }
> socket (9268) sending data synchronously without blocking [len=342]
> socket (9268) sent 342 bytes of data
> HTTP/1.1 200 OK
> Content-Type: application/json; charset=UTF-8
> Content-Location: http://localhost:8080/server/status
> Date: Tue, 19 Jan 2010 10:09:18 GMT
> Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
> Accept-Ranges: bytes
> Server: Restlet-Framework/2.0m6
> Transfer-Encoding: chunked
>
> 1F
> {"server changed":"production"}
> socket (9268) sending data synchronously without blocking [len=5]
> socket (9268) sent 5 bytes of data
> 0
>
> socket (9296) sending data synchronously [len=1]
> socket (9296) sent 1 bytes of data
> 0000 01 .
> socket (9328) can receive 1 bytes atomically
> socket (9328) receiving data synchronously [len=16]
> socket (9328) received 1 bytes of data
> 0000 01 .
> socket (9268) receiving data synchronously without blocking [len=4096]
> socket (9268) did not receive any data, closed gracefully by peer
> socket (9268) retrieved one of its options [level=SOL_SOCKET,
> optname=SO_LINGER, l_onoff=1, l_linger=1]
> socket (9268) will be closed when outstanding asynchronous calls finish
>
> *** with netty *** :
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) could not accept a connection - WSAEWOULDBLOCK (A
> non-blocking socket operation could not be completed immediately)
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) could not accept a connection - WSAEWOULDBLOCK (A
> non-blocking socket operation could not be completed immediately)
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) accepted a connection on new socket (9272)
> [addr=127.0.0.1:2369]
> socket (9272) specified an event object to be associated with the
> supplied set of network events and enabled its nonblocking mode
> [hEventObject=0, lEvent==0]
> socket (9272) disabled its nonblocking mode
> socket (9272) determined its local name [name=127.0.0.1:8080]
> socket (9272) determined its local name [name=127.0.0.1:8080]
> socket (9264) created [family=AF_INET, type=SOCK_STREAM,
> protocol=IPPROTO_IP, dwFlags=WSA_FLAG_OVERLAPPED]
> socket (9264) bound [name=127.0.0.1]
> socket (9264) established for listening [backlog=50]
> socket (9264) determined its local name [name=127.0.0.1:2370]
> socket (9264) determined its local name [name=127.0.0.1:2370]
> socket (9252) created [family=AF_INET, type=SOCK_STREAM,
> protocol=IPPROTO_IP, dwFlags=WSA_FLAG_OVERLAPPED]
> socket (9252) connecting synchronously [name=127.0.0.1:2370]
> socket (9252) connected
> socket (9252) sending data synchronously [len=8]
> socket (9252) sent 8 bytes of data
> 0000 2D 09 AA E0 9E B3 9A 2C -......,
> socket (9264) accepting a connection synchronously
> socket (9264) accepted a connection on new socket (9228)
> [addr=127.0.0.1:2371]
> socket (9228) specified an event object to be associated with the
> supplied set of network events and enabled its nonblocking mode
> [hEventObject=0, lEvent==0]
> socket (9228) disabled its nonblocking mode
> socket (9228) receiving data synchronously [len=8]
> socket (9228) received 8 bytes of data
> 0000 2D 09 AA E0 9E B3 9A 2C -......,
> socket (9264) retrieved one of its options [level=SOL_SOCKET,
> optname=SO_LINGER, l_onoff=0, l_linger=0]
> socket (9264) closed
> socket (9228) set one of its options [level=IPPROTO_TCP, optname=1]
> socket (9228) sending data synchronously [len=1]
> socket (9228) sent 1 bytes of data
> 0000 01 .
> socket (9252) can receive 1 bytes atomically
> socket (9252) receiving data synchronously [len=16]
> socket (9252) received 1 bytes of data
> 0000 01 .
> socket (9272) enabled its nonblocking mode
> socket (9272) receiving data synchronously without blocking [len=1024]
> socket (9272) received 217 bytes of data
> POST /server/mode HTTP/1.1
> Content-Length: 28
> Content-Type: application/json; charset=UTF-8
> Host: localhost:8080
> Connection: Keep-Alive
> User-Agent: Apache-HttpClient/4.0-beta2 (java 1.5)
> Expect: 100-Continue
>
> socket (9272) receiving data synchronously without blocking [len=807]
> socket (9272) could not receive data - WSAEWOULDBLOCK (A non-blocking
> socket operation could not be completed immediately)
> socket (9272) receiving data synchronously without blocking [len=807]
> socket (9272) could not receive data - WSAEWOULDBLOCK (A non-blocking
> socket operation could not be completed immediately)
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) could not accept a connection - WSAEWOULDBLOCK (A
> non-blocking socket operation could not be completed immediately)
> socket (9272) receiving data synchronously without blocking [len=1024]
> socket (9272) received 28 bytes of data (Incomplete last line)
> {
> "mode":"production"
> }
> socket (9272) receiving data synchronously without blocking [len=996]
> socket (9272) could not receive data - WSAEWOULDBLOCK (A non-blocking
> socket operation could not be completed immediately)
> socket (9272) receiving data synchronously without blocking [len=996]
> socket (9272) could not receive data - WSAEWOULDBLOCK (A non-blocking
> socket operation could not be completed immediately)
> socket (9272) sending data synchronously without blocking [len=331]
> socket (9272) sent 331 bytes of data (Incomplete last line)
> HTTP/1.1 200 The request has succeeded
> Accept-Ranges: bytes
> Content-Location: http://localhost:8080/server/status
> Content-Type: application/json; charset=UTF-8
> Date: Tue, 19 Jan 2010 10:15:37 GMT
> Server: Restlet-Framework/2.0m6
> Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
>
> {"server changed":"production"}
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) could not accept a connection - WSAEWOULDBLOCK (A
> non-blocking socket operation could not be completed immediately)
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) could not accept a connection - WSAEWOULDBLOCK (A
> non-blocking socket operation could not be completed immediately)
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) could not accept a connection - WSAEWOULDBLOCK (A
> non-blocking socket operation could not be completed immediately)
> [...] same things lots of time
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) could not accept a connection - WSAEWOULDBLOCK (A
> non-blocking socket operation could not be completed immediately)
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) could not accept a connection - WSAEWOULDBLOCK (A
> non-blocking socket operation could not be completed immediately)
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) could not accept a connection - WSAEWOULDBLOCK (A
> non-blocking socket operation could not be completed immediately)
> ********** I pushed the stop button **********************
> socket (9272) receiving data synchronously without blocking [len=960]
> socket (9272) did not receive any data, closed gracefully by peer
> socket (9272) retrieved one of its options [level=SOL_SOCKET,
> optname=SO_LINGER, l_onoff=0, l_linger=0]
> socket (9272) will be closed when outstanding asynchronous calls finish
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) could not accept a connection - WSAEWOULDBLOCK (A
> non-blocking socket operation could not be completed immediately)
> socket (9228) sending data synchronously [len=1]
> socket (9228) sent 1 bytes of data
> 0000 01 .
> socket (9228) retrieved one of its options [level=SOL_SOCKET,
> optname=SO_LINGER, l_onoff=0, l_linger=0]
> socket (9228) closed; bytes received=8, bytes sent=2
> socket (9252) retrieved one of its options [level=SOL_SOCKET,
> optname=SO_LINGER, l_onoff=0, l_linger=0]
> socket (9252) will be closed when outstanding asynchronous calls finish
> socket (9372) accepting a connection synchronously without blocking
> socket (9372) could not accept a connection - WSAEWOULDBLOCK (A
> non-blocking socket operation could not be completed immediately)
>
> Do anybody have a hint of what is going wrong ?
> I don't know if there is something I'm missing in the configuration of
> the connector, maybe ?
>
> Regards,
> Laurent
>
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2441813package test;
import org.restlet.Application;
import org.restlet.Component;
import org.restlet.data.Protocol;
import org.restlet.routing.Router;
public class MyApplication extends Application {
public static void main(String[] args) throws Exception {
Component c = new Component();
c.getServers().add(Protocol.HTTP, 8182);
c.getDefaultHost().attach("/test", new MyApplication());
c.start();
}
public org.restlet.Restlet createInboundRoot() {
Router router = new Router(getContext());
router.attach("/resource", MyResource.class);
return router;
};
}
package test;
import org.restlet.representation.Representation;
import org.restlet.resource.Post;
import org.restlet.resource.ServerResource;
public class MyResource extends ServerResource {
@Post
public String testPost(Representation rep) {
try {
return "hello " + rep.getText() + "\n";
} catch (Exception e) {
return e.getMessage();
}
}
}