I am using Netty 4.1-Beta6 version.
I want to support the use case where the HTTP2 server should be able to push events to the HTTP2 client on an existing connection - this could be an alarm or timer event from the cloud which needs to be propagated to the client.
I am thinking of using 'Server Sent Event' feature - is it possible to do this with HTTP2 in Netty, if so, how? Should I keep a http2 stream open by sending data frames with 'final frame' flag set to false? When I try this, what I observe is that the content gets buffered. The data frame doesn't reach the client as and when I write. I am using the DefaultHttp2Encoder. I tried setting the 'Transfer-Encoding' header to 'chunked' too.
Related question - does HTTP2 allows bi-directional data frames once the stream is in 'open' state? The idea is that the server should be able ask data from the client and client should be able to respond with the data in the same stream (reversal of client/server role once the stream is established). Is this possible?
Thanks in advance for the help.
I played with Netty bit more. Here is what I found for the 2 questions above.
Both the client and server can keep the stream in 'open' state by sending 'endOfStream' as false when they send the header/data frames. In order to avoid the buffering of data on the server side, I had to invoke flowController.writePendingBytes() followed by ChannelHandlerContext.flush()'.
I have uploaded my sample here - https://github.com/skssfo/http2
Yes, the client and the server can keep the stream open and send data frames independent of each other.
I am playing with Netty for the first time, it is very cool. Nice job Netty team!
Related
I am looking for a way to dump http request & reaponse body (json format) in resteasy on wildfly 8.2.
I've checked this answer Dump HTTP requests in WildFly 8 but it just dumps headers.
I want to see the incoming json message and outgoing one as well.
Can configuration do it without filter or any coding?
Logging HTTP bodies is not something frequently done. That's probably the primary reason for RequestDumpingHandler in Undertow only logging the header values. Also keep in mind that the request body is not always very interesting to log. Think for example of using WebSockets or transmitting big files. You can write your own MessageBodyReader/Writer for JAX-RS, and write to a ByteArrayOutputStream first, then log the captured content before passing it on. However, given the proven infeasibility of this in production, I think your mostly interested in how to do this during development.
You can capture HTTP traffic (and in fact any network traffic) using tcpflow or Wireshark. Sometimes people use tools such as netcat to quickly write traffic to a file. You can use for example the Chrome debugger to read HTTP requests/responses (with their contents).
How do you know if a socket server or web server is done transmitting a HTTP GET request when using ProgressEvent.SOCKET_DATA ?
I doing my socket request with socket.writeUTFBytes('GET /index.php HTTP/1.1\r\n');
But the 'answer' is so big that i get multiple ProgressEvent.SOCKET_DATA. How do i know how much data it is supposed to transmit to me ? Or when it's done transmitting ?? Or even how many progressEvents i will get out of this request ? So far I'm using a timer that checks if the server is still transmitting but this isn't a very clean way of doing things..
How do i know how much data it is supposed to transmit to me? Or when it's done transmitting ??
By reading the Content-length header if that is sent by the server, or by waiting until the server closes the connection, or by reading until you've encountered a last-chunk (0<CRLF><CRLF>) if chunked transfer encoding is enabled, or any of the other indications that a full response has been received.
For simplicity, use a HTTPService or if that doesn't fit your needs, use a library that implements an HTTP client.
Or even how many progressEvents i will get out of this request ?
There is no way to tell.
I have an application that connects to an AMF gateway exclusively (in a certain mode) and I have a service that renders some HTML that I want to display in a new window outside of the Flex application.
Is it possible, in Flex, to use navigateToURL to send an AMF object and open the response in a new window?
EDIT: More specifically, does anyone have insight into how an AMF request can be properly constructed in actionscript and sent via the POST data of a URLRequest?
UPDATE: Still looking for a clear spec for AMF that makes it obvious how to construct the service call related headers in AMF and what headers are required. Some guidance in this area would be helpful. I've done more reading and have seen some people talk about some custom solutions they have that work in a similar way to what I've mentioned above, although it seems like those solutions are guarded assets. But this further enforces my belief that this is quite possible.
I'd say no... Even if you could create an AMF packet by hand in AS3, how would you pass it to the URL using navigateToURL? How would the browser know how to handle the AMF values returned from your service call?
I suggest you call the AMF gateway service in your Flash app; do the processing that needs done; and then return a URL to the results. In the result handler method, you can open the URL using navigateToURL.
#Flextras is along the right lines - the AMF gateway in particular with AMFPHP isn't used with a URLRequest, instead you use the RPC remoting - most typically RemoteObject where you specify the receiving gateway (ie: endpoint or more generically the destination channel - but this one needs to be in your services-config which resides on the server), and you typically assign a responder to handle the result/failure events (in which your response is almost always a class marked as a [RemoteAlias]).
See: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/remoting/mxml/RemoteObject.html#includeExamplesSummary
When an "onmessage" event fires in the web socket protocol are you guaranteed the full message or is it more like a straight TCP connection where you buffer the data first and then try to extract packets.
There is protocol level support for fragmented messages and streaming. But this behavior is not represented in the current Javascript API, (reference). So yes, if you receive a message, it is indeed an entire message even if it was sent as many fragments.
I put together an applet that uploads images via as3httpclientlib to a servlet. The applet works fine in debug mode (through flash builder) and until today it worked when deployed.
From the servlet logs, it appears the servlet never receives the image(s) byte stream, therefore my hunch is the applet is not posting the multipart data.
Can anyone suggest what I should do next to find the cause of the problem?
I suppose you ran into problem described here:
In Flash Player 10 and later, if you
use a multipart Content-Type (for
example "multipart/form-data") that
contains an upload (indicated by a
"filename" parameter in a
"content-disposition" header within
the POST body), the POST operation is
subject to the security rules applied
to uploads:
The POST operation must be performed
in response to a user-initiated
action, such as a mouse click or key
press.
If the POST operation is
cross-domain (the POST target is not
on the same server as the SWF file
that is sending the POST request), the
target server must provide a URL
policy file that permits cross-domain
access.
So I think you should run your application using debugger and check Flex client logs for exceptions described above.