I have a problem with a server, written in Java, running on Tomcat, serving video files. I didn't write the code and have very little familiarity with the libraries involved in this problem, so any ideas to pursue would be much appreciated :)
The videos in question work fine when you save them to disk from your browser and then play them.
However, when you try to view one using a video-playing browser plugin (doesn't seem to matter which plugin ... WMP for either FF or IE, VLC in FF, doesn't matter which browser version either), it all goes wrong. From the browser end, no data seems to reach the plugin (so the VLC plugin, for example, just says "waiting for video" ... it never arrives).
On the server end, there's an HttpServletResponse instance, it calls getOutputStream on this, writes the data to the stream with no problem, and then an exception is thrown when closing the stream.
The exception stack trace is as follows:
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:750)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:432)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:347)
Any ideas? :)
Have you tried flushing the stream before you close it? In general you should not close the response's OutputStream yourself, the servlet container will do that as the last thing before it completes the request.
Does the HTTP response header contains a Content-Disposition field? If so, try to remove it to let the client decide the presentation method.
Spec: RFC 2183.
Ok so I finally got to the bottom of this. It really has nothing to do with Tomcat or Java, the key is the difference between how the browser fetches the data and how the browser plugin fetches it: the plugin doesn't send the browser's cookies.
In this case, the server had some login cookie stuff, so the plugin's request for data was denied before it ever got to being written to a stream. What was confusing here was that in the debugger, the stream-writing code was still being run, but that was just because the browser requests the data first (once it realises it has a video, it fires up the plugin instead and the plugin makes a fresh HTTP request).
I discovered this with Wireshark btw where the response to the plugin was clear (it was an HTML "access denied" kind of page).
Related
Back from my post here
Glimpse making everything 50x slower
It was fixed but now is broken again.
It seems to again try to hash every bit of data in the relationships of tables even though the code doesnt do this, glimpse forces this.
Because of this glimpse isn't responding and we get the error
No data has been found. This could be caused because:
- the data is still loading by the client, or
- no data has been received from the server (check to see if the data & metadata payloads are present), or
- no plugin has been loaded, or
- an error has been thrown in the client (please check your JavaScript console and let us know if anything is up).
this is what it looks like in chrome
http://puu.sh/cF3xX/0f879fac9c.png
this is what ends up happening debugging locally
http://puu.sh/cF2c6/e10ca1b6e0.png
If you are using Entity Framework, make sure you are not using any data model in the Views. This can cause the issue that you described due to lazy loading attempting to map all the connections (relationships).
I'm creating a simple webpage with NodeJS that'll upload a picture, resize it, pull some information from the web about the picture, and then save to the database. Easy stuff, all of it done server side. Though I'm trying to write an new feature that I'm a bit lost on how to go about. What I'd like to do is 'print' to the client when it's started each step of the process I mentioned about.
Imagine it like a white box, and every time something happens on the server, a new line is written says what for the client to read. How would I go about this? Any help is appreciated!
Use socket.io or some other websocket library. When the page loads, open a connection (in the browser's javascript). On the server, as events happen, send them as socket.io messages. In the browser, as events arrive, set them into a "status" element or append them to a list or whatever. You should be able to find lots of examples of chat servers out there and just convert chat messages to progress updates and there you have your architecture.
http://howtonode.org/websockets-socketio
Try something, then post a code snippet.
I am using the Domino Data Access (via RESTClient) to update docs in a database. I'm using PATCH and PUT. In both cases (PATCH is a header override) I don't get a response back from the Domino server. RESTClient gives me a "processing data" and that's it. If I abort, I can see the replace or update has been done. So DDA is working, except I'm not getting a 200 or other response back. Default and Anonymous can create/edit (database is still in testing), and I've tried with and without the form and computewithform parameters. I'm not seeing anything in the server log.
Could someone give me a pointer of where to look? It seems that something is keeping the complete acknowledgment from being sent, but I don't know what that would be. Other testing, for GET, respond fine.
Thanks,
Brian
urns out this was a problem with RESTClient, not DDA/DDS. Thanks to Fotios Hatzis who figured it out. I tried with a Chrome extension, and the response displays as exected. –
My question has similar point like this one.
I’m wondering how I can catch a media URL which SWF loads from browser add-on. Let’s say YouTube flash player starts playing or loading some video (let it be via http) and I want to know that url. Just like browser plugins from “RealDownloader” and “Moyea YouTube FLV Downloader” does. I’m newbie with plugin development and flash and I want to know what technologies it may be. XPCOM, NPAPI, ActiveX, or simple API hooking. Any ideas how this may be accomplished?
NPAPI plugins typically ask the browser to load data for them, they don't do it themselves. This means that a browser extension can intercept these requests. This can be done for example by implementing a content policy. Requests initiated by a plugin will cause a shouldLoad call with type OBJECT_SUBREQUEST.
The simpler option is using HTTP observers - but this way you won't recognize requests initiated by Flash, they will look just like any other request processed by the browser.
Firebug does that, and it's open source. Why not study it a little?
https://github.com/firebug/
It's easy if you only want to get the url from a single swf in a single website. for example if all you need are urls from that swf,you can keep only one instance of your browser open and use a tool to intercept its http requests.
I push [script]dosomething()[/script] tags into the iframe for my comet server using chunked data, but script tags just continues to accumulate forever. How do I wipe it after every script tag?
Wipe script tag
P.S: When you want to wipe script tags it is probably to follow Does comet server data in the iframe just accumulate?
I believe you should close the connection after sometime(no good, see Does comet server data in the iframe just accumulate? instead) which automatically frees up the memory associated with that request. You then off course need to reconnect. This page says something else even:
"Page Streaming" means the browser
discovers server changes almost
immediately. This opens up the
possibility of real-time updates in
the browser, and allows for
bi-directional information flow.
However, it's quite a departure from
standard HTTP usage, which leads to
several problems. First, there are
unfortunate memory implications,
because the Javascript keep
accumulating, and the browser must
retain all of that in its page model.
In a rich application with lots of
updates, that model is going to grow
quickly, and at some point a page
refresh will be necessary in order to
avoid hard drive swapping, or a worse
fate.
This advices to reload the page which is also an option. But I think closing that connection(iframe) and reconnecting might also work.
Comet has a lot of problems you need to hack around:
As you can read from this WIKI page it also has problems with "reliable error handling method, and the impossibility of tracking the state of the request calling process.".
Also Internet Explorer needs to sent some junk to get the process started(see http://cometdaily.com/2007/11/05/the-forever-frame-technique/)
That's why I again recommend you to use socket.io(see below) which takes care of all this nonsense.
Socket.io
I advice you to use socket.io instead, which is very good product. It is supported by all major browsers. As you can see it support a lot of transport(XHR, Websockets, etc) and choices the best one available on your browser for the best performance.
Wipe script tag without reconneting
You can remove script tag every time that it is executed by adding some code when the server prints chunk.
<script type="text/javascript">
// Calls your message handler
app.handle("Hello World");
// Removes this script element
var scripts = document.getElementsByTagName("script"),
elem = scripts[scripts.length - 1];
elem.parentNode.removeChild(elem);
</script>
Compressed version
<script type="text/javascript">
app.handle("Hello World");
(function(){var a=document.getElementsByTagName("script"),a=a[a.length-1];a.parentNode.removeChild(a)})();
</script>
But, Hidden Iframe or Forever Iframe is too annoying to use as Alfred mentioned. Personally, I think this classical way makes Comet look graceless and charmless.
jQuery Stream
My recommendation is to use jQuery Stream, which provides the unified two-way communication interface over WebSocket and HTTP protocol. It is a light-weight client-side JavaScript Library such as jQuery.
The enhanced Iframe transport being used by jQuery Stream is different from the classical one in many ways, requries text/plain response containing only messages instead of text/html response and empties the response every time that it's handled.
According to some user's test, Internet Explorer 8 using enhanced Iframe transport has no problem with messages of several megabytes (unlike Firefox using XMLHttpRequest as transport, which is really struggling).