Results 1 to 16 of 16
Like Tree1Likes
  • 1 Post By jim829

Thread: Not A Java Question (it's about the http protocol)

  1. #1
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Not A Java Question (it's about the http protocol)

    Greetings,

    I am testing a tiny embedded system (no OS, 8KB RAM, 256KB Flash ROM); it can act as a tiny http server (it can handle GET and POST messages). The thing was tested with a Java client that fires GET and POST messages and checks the results. The little thing ran fine for even weeks. When I connect an ordinary web browser to that embedded thing, things go berzerk; and I think I know why: my Java test bench fires one GET or POST request, waits for the reply, checks it and starts the loop again. It runs single threaded in lock step with that tiny embedded thing. Not so with a browser: e.g. if a GET query results in an html page with a couple of images, the GET queries for the images are fired almost at the same time (possibly at different threads).

    That poor single threaded embedded thing stands with its back against the wall: while handling the first GET query for the first image, a socket is opened for the second GET query (for the second image) and that embedded thingy loses track and sends the result of the first query over those two sockets. Note that the socket handling is beyond my control; it is handled by a cheap (Chinese) WiFi-serial bridge, iow that embedded thing doesn't even know it's talking over WiFi, all it knows about is a serial connection.

    My question boils down to this: would it be possible to make a browser act in a single threaded way, preferably by adding a few http headers? I couln't find anything useful, hence my question ...

    kind regards,

    Jos

    ps. that http server stuff is just a small part in that embedded thing; it can control things, e.g. it also has a 433MHz interface to control lamps, doors etc. It is also way too small (and too slow) for a multi threaded something; it can hardly handle all the interrupts coming in ;-)
    Last edited by JosAH; 07-29-2013 at 10:47 AM.
    cenosillicaphobia: the fear for an empty beer glass

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Not A Java Question (it's about the http protocol)

    This is IE, and appears to be a registy setting...
    Different OS/version/etc will undoubtedly involve a different key.

    Got that from reading this.

    Now, if IE has this tucked away, then it's possible there's a similar thing for the others?

    Of course, I have no idea what knock on effects setting the max connections per server will have.
    And it is also only per server, so if you're fetching from multiple places then this will not solve your problem.
    Indeed I wouldn't be surprised to find that you cannot prevent concurrent requests in any reasonably modern browser...it's been a feature since the year dot.

    So...write your own browser?
    :)
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,367
    Rep Power
    6

    Default Re: Not A Java Question (it's about the http protocol)

    yeah or some horrible Ajax hack; in stead of letting the browser fetch the additional resources, do it with Javascript. Ugh, I feel sick to my stomach for even suggesting it. I don't even know if that would work with js and css resources.

    Generally request throttling is of course done on the server, not on the client.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Not A Java Question (it's about the http protocol)

    Quote Originally Posted by Tolls View Post
    This is IE, and appears to be a registy setting...
    Different OS/version/etc will undoubtedly involve a different key.

    Got that from reading this.
    Thanks for the reply; I happen to have IE10 installed and MS only offers a 'fixit' program for it; the 'fixit' program doesn't find any problems (which I can imagine because I want to slow IE10 down ;-) I keep on reading those links, maybe I find something that I also want an end user to do him/herself.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Not A Java Question (it's about the http protocol)

    Quote Originally Posted by gimbal2 View Post
    yeah or some horrible Ajax hack; in stead of letting the browser fetch the additional resources, do it with Javascript. Ugh, I feel sick to my stomach for even suggesting it. I don't even know if that would work with js and css resources.

    Generally request throttling is of course done on the server, not on the client.
    That could be a solution: let JavaScript download those picture files one by one. Part of my problem is that WiFi-serial bridge; everthing works fine with just one tcp connection; i.e. it serves as a virtual serial wire. If more connections are made (that bridge can handle four of them) all output over the serial connection is output for all tcp connections.

    thanks for the reply and

    kind regards,

    Jos

    ps. now I have to learn just enough JavaScript to do the job ;-)
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,033
    Rep Power
    6

    Default Re: Not A Java Question (it's about the http protocol)

    You asked if you could add Http headers to the browser. This implies you have some control over the source. Could you write a proxy front end to the browser to intercept the requests and process them individually. Of course, eventually the queue would fill up depending on the activitiy of the client.

    Regards,
    Jim
    gimbal2 likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,367
    Rep Power
    6

    Default Re: Not A Java Question (it's about the http protocol)

    Quote Originally Posted by JosAH View Post
    That could be a solution: let JavaScript download those picture files one by one. Part of my problem is that WiFi-serial bridge; everthing works fine with just one tcp connection; i.e. it serves as a virtual serial wire. If more connections are made (that bridge can handle four of them) all output over the serial connection is output for all tcp connections.

    thanks for the reply and

    kind regards,

    Jos

    ps. now I have to learn just enough JavaScript to do the job ;-)
    Needless to say, your virtual TCP thingie is not built to act as a proper HTTP server ;)

    jim's idea or a variant thereof is actually quite interesting too, to put a "man in the middle" which takes the multiple requests and then handle the queuing in that proxy. My inner geek would actually attempt that and not go for the... *hurk*, excuse me, javascript "solution".
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Not A Java Question (it's about the http protocol)

    Quote Originally Posted by jim829 View Post
    You asked if you could add Http headers to the browser. This implies you have some control over the source. Could you write a proxy front end to the browser to intercept the requests and process them individually. Of course, eventually the queue would fill up depending on the activitiy of the client.
    Thanks for the reply; where should I run this 'middle man'? The thing is supposed to be for an end user; I can't demand that they set up a proxy server (hoping that they even know what it is). All they have to do know is supply a tcp address and the thing does the rest. My dedicated client (written in Java) runs on any PC on the same network and does all the configuration needed. I want that http server to be able to control that embedded thing from anywhere without any additional software needed ... but Gimbal is right: that WiFi-serial bridge isn't suited for the job ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Not A Java Question (it's about the http protocol)

    Quote Originally Posted by gimbal2 View Post
    Needless to say, your virtual TCP thingie is not built to act as a proper HTTP server ;)

    jim's idea or a variant thereof is actually quite interesting too, to put a "man in the middle" which takes the multiple requests and then handle the queuing in that proxy. My inner geek would actually attempt that and not go for the... *hurk*, excuse me, javascript "solution".
    True, that WiFi-serial bridge doesn't do what it's supposed to do; I'm looking for other hardware right now (including the micro controller); I'm currently looking at this thing: Community: BeagleBone Black - element14. It looks interesting; all I need is a wireless dongle (I think).

    Everything currently runs on an Atmel AtMega2560 and that Chinese WiFi-serial bridge (and then some) ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,033
    Rep Power
    6

    Default Re: Not A Java Question (it's about the http protocol)

    I assumed since you were considering making a change to the headers as a possibility that any other similar change would be acceptable (since most users would not be able to make those header changes either -unless you were thinking of some basic configuration change and not code modification). If you simply wanted to be able to take existing browsers and single thread their requests without modification then clearly my suggestion wouldn't work.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  11. #11
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,367
    Rep Power
    6

    Default Re: Not A Java Question (it's about the http protocol)

    Well you could package it as a Java application and use an embedded Jetty server as your "man in the middle" - in stead of directly talking to the device, the client would talk to your server and that server then talks to the device in a controlled manner. But perhaps getting better hardware is the way to go :)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  12. #12
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Not A Java Question (it's about the http protocol)

    Quote Originally Posted by jim829 View Post
    I assumed since you were considering making a change to the headers as a possibility that any other similar change would be acceptable (since most users would not be able to make those header changes either -unless you were thinking of some basic configuration change and not code modification). If you simply wanted to be able to take existing browsers and single thread their requests without modification then clearly my suggestion wouldn't work.
    Sorry for being unclear; certainly I can change those headers; aamof when the tiny http server receives a GET /XXX requests, it simply searches for a block named 'XXX' on an SD card (it doesn't have a proper file system ;-), processes its content for expressions it understands and sends the result to the client again. Those headers are part of the content of 'file' XXX.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  13. #13
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Not A Java Question (it's about the http protocol)

    A small update: I went for Gimbal's solution. Note that this is (c) (tm) (r) by Gimbal and Gimbal alone ;-)

    I defined the images in the html file as follows:

    Java Code:
    <img> tag="this is the first image">
    <img> tag="this is the second image">
    <img> tag="this is the third image">
    Note that I didn't define the source of the image. When the entire page is loaded, I fire an event (the onLoad event):

    Java Code:
    function onLoadHandler() {
       setTimeout(function(){ document.images[0].src='first.img'; },   100);
       setTimeout(function(){ document.images[1].src='second.img'; }, 500);
       setTimeout(function(){ document.images[2].src='third.img'; },  900);
    }
    Note that IE10 schedules those three events almost simultaneously so I had to set those times large enough to give my single threaded little embedded server some time to send the contents of an image. It works for IE10, the Chrome browser on a Samsung tablet, a browser on my old Samsung phone, Firefox on a Linux box and tonight I have to steal^H^H^H^H^Hborrow my wife's iPad to see if that works too ...

    The visual appearance of it all is quite funny: the page resembles how good ol' Motif wiggled its components to their correct position.

    Thanks to all for the replies and thanks to Gimbal for this beautiful solution ;-)

    kind regards,

    Jos
    Last edited by JosAH; 07-30-2013 at 12:47 PM.
    cenosillicaphobia: the fear for an empty beer glass

  14. #14
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,367
    Rep Power
    6

    Default Re: Not A Java Question (it's about the http protocol)

    Argh! I'm going to hell!
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Not A Java Question (it's about the http protocol)

    Quote Originally Posted by gimbal2 View Post
    Argh! I'm going to hell!
    Burn, baby, burn...as they say.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  16. #16
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Not A Java Question (it's about the http protocol)

    Quote Originally Posted by gimbal2 View Post
    Argh! I'm going to hell!
    Yes, and I'm going to heaven for not knowing all this dirty crap; while I'll be surrounded by scantily clad women en cold Grolsch, you have to program in that terrible blasphemy of a language ;-)

    kind regards,

    Jos

    ps. it all runs fine now ;-)
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. JNLP(Java Network Launching Protocol)
    By mitra in forum Networking
    Replies: 0
    Last Post: 07-28-2011, 02:48 PM
  2. Replies: 3
    Last Post: 07-22-2011, 10:25 AM
  3. Replies: 4
    Last Post: 10-30-2010, 11:16 AM
  4. java.net.MalformedURLException: no protocol:
    By john_thomas03 in forum New To Java
    Replies: 3
    Last Post: 07-27-2010, 08:28 AM
  5. java.net.MalformedURLException: unknown protocol: ntp
    By Nicholas Jordan in forum Networking
    Replies: 6
    Last Post: 12-24-2008, 04:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •