Shop OBEX P1 Docs P2 Docs Learn Events
[Contest Entry] Multi-Socket Server - Page 2 — Parallax Forums

[Contest Entry] Multi-Socket Server

24

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-08-22 19:27
    ''william wrote:
    If a browser tries to make lets say 8 simultaneous socket connections to HTTPServer, will it result in error messages or will the 5-8 connections politely wait their turn for a free wiznet socket each?

    It really depends on the browser and the number of bytes requested. It's common for 2 sockets to handle a potential 4 socket request. Likewise, a potential 4 socket request could consume all 4 sockets.

    An error message requires that a socket actually handled the request. Errors come in the form of a poorly formatted web page because the CSS file was not downloaded or a red X in place of a missing image. Again, it depends on the browser. Firefox tends to give up and cancel a request where MACs running Safari seem to churn waiting for a response that may never complete.

    Socket management is a huge concern when working with only 4 sockets.
  • william chanwilliam chan Posts: 1,326
    edited 2011-08-22 23:37
    There must be a way.for HTTPServer to advise the browser to limit itself to only 1 socket connection at a time.
    Maybe the Wiznet creators can give us some pointers.

    Why does HTTPServer need to have a RemoteTCP server?
    What is the use of having a remote server?
  • Mike GMike G Posts: 2,702
    edited 2011-08-23 06:19
    There must be a way.for HTTPServer to advise the browser to limit itself to only 1 socket connection at a time.
    Web servers fulfill client requests. A web server has no control over the number of client sockets requested. Plus HTTP is an anonymous protocol.

    Caching can be used to limit sockets requests by retrieving resources downloaded to the client's local cache. Set globalCache to a 1 to cache all requests in HTTPServer.
    globalCache           byte    $1
    

    Some browsers have configuration that limit the number of socket connections. However, this is a client setting. Folks would be up in arms if a server started changing client browser settings.
    Why does HTTPServer need to have a RemoteTCP server?
    HTTPServer does not need a remote TCP call. I want to make remote TCP calls. Plus a remote IP is a default W5100 configuration. Please see the W5100 manual.
    What is the use of having a remote server?
    To execute logic on a remote server like sending email, writing to a database, solving complex math problems...

    Here are a few resources to help your understanding of HTTP and Web Servers.
    http://spinneret.servebeer.com:5000/
    http://www.w3.org/
    http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/spinneret/List/0/SortField/4/ProductID/710/Default.aspx
    http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/W5100Datasheetv1.2.2.pdf
  • PaulPaul Posts: 263
    edited 2011-08-23 10:50
    Mike G wrote: »
    Thanks Paul, which images are you referring to, the links? What browser are you using and platform?
    Hi Mike.
    Ms-XP, Firefox 3.6.12. The image on the main page for one. But the good news is it took me 4 reloads to get this today. Friday it was almost every time. The image usually disappears if it gets "torn up" like the attach file shows. Maybe it is load sensitive?
    Paul
    1024 x 818 - 132K
  • Mike GMike G Posts: 2,702
    edited 2011-08-23 15:19
    Thanks Paul, It's a relatively large file. I can't seem to reproduce the issue. I hit the image from several locations, home office, work, friend's house, etc. I'm not sure what's going on.
  • PaulPaul Posts: 263
    edited 2011-08-24 20:25
    Congrats on the contest win, Mike. I don't think anyone is surprised. You did a great job!
    Paul
  • Roy ElthamRoy Eltham Posts: 2,996
    edited 2011-08-26 10:49
    http://spinneret.servebeer.com:5000/ appears to be down for me... tried several times.
  • Mike GMike G Posts: 2,702
    edited 2011-08-26 18:21
    Darn... Something happened. Well the Spinneret ran for about 2 months before locking up. Unfortunately, I disconnected the logger and serial terminal so I have no idea what the last request was. So if anyone locked the Spinneret I'd like to hear for you.

    EDIT: turned on the logger.
  • marzec309marzec309 Posts: 146
    edited 2011-09-03 17:02
    Very nice project and congrats on your win. I just want to point out, in your source files for the HTTPServer, the request object is missing the "Post(id, pname)" method. Works great except for the "POSTing to the server" page (wont compile with this method missing).

    Again Congrats.


    P.S. I just figured out how to turn on your Spinneret user led. look its on ;)
  • Mike GMike G Posts: 2,702
    edited 2011-09-03 20:12
    marzec309, thank you for the heads-up. I updated all archives files.

    And yes I saw the user LED was on ;)

    A little stat update. The Spinneret served up ~4000 requests in the last couple of days. Some are search engine crawlers but a fair amount are folks reading the tutorial. Please let me know if you find errors. I'll do my best to fix the errors quickly. If there is functionality you would like added, please just let me know. I can't make make any promises but I can certainly look into the request..

    Right now I'm looking at SNMP because of this thread.
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2011-09-05 16:09
    I've been working on an SPI version of Mike's great software for use with the ETHShield and the Propeller ASC. I have HTTPServerBase.spin successfully communicating with the W5100 setting and reading configurations. But I've hit a wall and can't go any further without some help. I've narrowed the problem down (maybe)to memory locking.
    CmdWait
    '----------------------------------------
    ' Mike Gebhard 4/17/2011
    ' Writes all 4 status register values
    ' to HUB ram during idle time waiting
    ' for a command
    '-----------------------------------------
    :init_state   mov       statereg, stsreg0       ' status register 1 $0403 
                  mov       statests, stateidx      ' point to status[0]
                  mov       counter, #4             ' countdown 4, 3 ,2 ,1, 0
    :mem_lock     lockset   stssemid           wc
            if_c  jmp       #:mem_lock
    :write_ram    mov       reg, statereg           ' Register address ($0403)
                  mov       ram, statests           ' destination of socket's status byte
                  mov       ctr, #1                 ' We're just moving one byte
                  call      #ReadMulti              ' Execute the command
                  add       statereg, #$0100        ' Next socket register $0403 + $100
                  add       statests, #1
                  djnz      counter, #:write_ram    ' Do this 4 times
                  lockclr   stssemid
    '-----------------------------------------
    ' End of 4/17/2011 update
    '-----------------------------------------               
    :skip_cmd     rdlong    cmdAdd, par        wz   'Check for a command being present
            if_z  jmp       #CmdWait                'If there is no command, jump to check again
    

    From what I can tell this part of the main PASM loop is only letting the semaphore unlock for 700nS and staying locked for 19.5uS. That's ~94.6% in a locked state and the unlocked window is so short that the SPIN lockset() below is only getting a lock every few hundred iterations of the PASM lockset.
    PUB GetStatus32(writeTo) | i
      repeat until not lockset(statusSemId)  '<--- We seem to wait here forever...
      repeat i from 0 to 3
        byte[writeTo][i] := status[i]
      lockclr(statusSemId)
    

    This appears to be the blockage but I could be totally wrong. I've been flailing at it for a couple of days and had to admit defeat. Current version (with gobs of debug code added) attached. Hoping that someone spots an obvious error in my mod.

    HTTPServerBase - Archive [Date 2011.09.05 Time 19.06].zip
  • Mike GMike G Posts: 2,702
    edited 2011-09-05 21:53
    Martin Hodge, what happens when you invoke a potential dirty read? That negates the memory lock.
    PUB GetStatus(id) : value
      value := status[id]
    

    OR
    ' Read all 4 bytes
    PUB GetStatus32(writeTo) | i
      'repeat until not lockset(statusSemId)                    '======================PROBLEM HERE======================
      repeat i from 0 to 3
        byte[writeTo][i] := status[i]
      lockclr(statusSemId)
    

    Frankly, I've never been able to get to the demo SPI driver to function. Do you have the demo SPI driver working without the mod?
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2011-09-06 08:16
    Commenting out the lock in GetStatus32 allows it to get all the sockets to the "LSTN" state, but it's dead after that. Is the serial output supposed to continuously update?

    The demo SPI driver works fine, out-of-the-box, on the ETHShield. Strange that it won't work on the Spinneret, all the connections are there.
  • Mike GMike G Posts: 2,702
    edited 2011-09-06 09:21
    Is the serial output supposed to continuously update?
    I'm not totally sure what you are referring to but the status registers are continuously polled and their state is written to RAM. In your case, this is over an SPI link.
    The demo SPI driver works fine, out-of-the-box, on the ETHShield. Strange that it won't work on the Spinneret, all the connections are there.
    You have TCP to working using W5100_SPI_Driver.spin? Please post your working code. I've had the UPD demo working but I was never was able to get TCP working on W5100_SPI_Driver.spin.

    What's a ETHShield? Is there a datasheet?

    Edit: I just tried the W5100_SPI_Driver.spin and W5100 UDP Echo Demo SPI Ver. 00.4 from the Google repository. I can't get the W5100 to initialize. I tried your code and just got weird characters in PST. It seems to occur when starting the SPI driver. I kinda' suspect that the I/O is not configured correctly for the Spinneret, not sure though. I'll look into it later tonight.
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2011-09-06 10:55
    Mike G wrote: »
    I'm not totally sure what you are referring to but the status registers are continuously polled and their state is written to RAM. In your case, this is over an SPI link.

    I wasking about the serial terminal readout on PST. It was a lazy question though, I'll figure it out.
    Mike G wrote: »
    You have TCP to working using W5100_SPI_Driver.spin? Please post your working code. I've had the UPD demo working but I was never was able to get TCP working on W5100_SPI_Driver.spin.

    Here's an archive

    It's just the web server demo from the Google repository. Swapped out the OBJ and made sure MOSI, MISO, CLK and /SCS are set to the correct pins in the configuration. Also SEN (tied to P15) will need to be asserted high on the Spineret to put the W5100 in SPI mode. SEN is permanently tied high on the ETHShield, so you won't find code in there to do that (outa[15] := 1). From what I can tell from the Spineret schematic the correct pins should be:
      '~~~~Propeller Based I/O~~~~
      'W5100 Module Interface
      _WIZ_miso     = 0
      _WIZ_mosi     = 1
      _WIZ_scs      = 2             
      _WIZ_sclk     = 3
    
    Mike G wrote: »
    What's a ETHShield? Is there a datasheet?

    http://www.arduino.cc/en/Main/ArduinoEthernetShield
  • william chanwilliam chan Posts: 1,326
    edited 2011-09-06 16:55
    Roy Eltham wrote: »
    http://spinneret.servebeer.com:5000/ appears to be down for me... tried several times.

    I can't access it too. After the browser (Firefox) established connection, the connection becomes lost.
  • Mike GMike G Posts: 2,702
    edited 2011-09-06 18:27
    The server is up has has been up since Roy's post. The server logged a little over 4000 requests today. It might have something to do with my home network.
  • william chanwilliam chan Posts: 1,326
    edited 2011-09-08 05:26
    Could it be that most of the 4000 requests did not complete properly?
    For example, maybe the connection was accepted but the html data was not fully sent out.

    I still can't access it.
  • mindrobotsmindrobots Posts: 6,506
    edited 2011-09-08 07:12
    Mike,

    The first time I tried to access your site (about 5 mins ago), the request went out from Firefox and then it just started clocking time. I closed that tab and tried again and got connected. Now, I've been hitting it, trying menus, loading and reloading various pages without any troubles. Now it consistently works like a champ!
  • Mike GMike G Posts: 2,702
    edited 2011-09-08 09:50
    Thanks for the confirmation Rick :)
    Could it be that most of the 4000 requests did not complete properly?
    Possibly, but I've had positive feedback on the tutorial. I assume that folks are getting through.

    The Spinneret is getting hit pretty hard lately. From 7:30 to 8:30am PST the Spinneret logged around 200 requests. Many of the requests come in on the same second. I imagine there is some concurrency issues with the 4 socket device.

    William please try issuing a service command. The LED state is echoed back to the caller in XML.
    http://spinneret.servebeer.com:5000/led/25/on

    You could also try access through a web server. Just click the LED On/Off links.
    http://www.agaverobotics.com/spinneret/controlpanel.htm
  • mindrobotsmindrobots Posts: 6,506
    edited 2011-09-08 14:24
    Mike,

    I just followed the first part of your tutorial (through to Hello World) and all worked as simply and easily as advertised. I downloaded your httpserv.zip changed the parameters to match my config, created an index.htm on my sd card, loaded it all up and it worked like a champ. I've externalized it at http://50.43.142.149:8080 and was able to reach out from outside my network and reach myself!

    Excellent work! Now it's time to build a meaningful web site,,,and clean up the pile of wires and boards that make up my web server!!

    First off, I need a cool favicon.ico file!!

    Thanks for the great work, Mike!!
  • Mike GMike G Posts: 2,702
    edited 2011-09-09 07:26
    Rick, glad it worked for ya.

    @william chan, I set the logger up to monitor IP. Let me know if you try requesting a page so I can look at the log and hopefully see what's going on.
  • william chanwilliam chan Posts: 1,326
    edited 2011-09-09 08:15
    I just tried the main page again about 1 minute ago. I can see the page after about 10 refresh tries.

    For the LED link, I get the XML also after about 10 to 20 tries.

    Access thru the web server works well.
  • Mike GMike G Posts: 2,702
    edited 2011-09-09 08:19
    william chan, is it any quicker when you go through http://www.agaverobotics.com/spinneret/controlpanel.htm? Could be some funky with your Malaysia IP 113.210.101.143 and my ISP.
  • Mike GMike G Posts: 2,702
    edited 2011-09-09 08:47
    william chan, I did a trace route on your IP. It gets pretty slow after reaching Singapore.
    C:\>tracert 113.210.101.143
    
    Tracing route to 113.210.101.143 over a maximum of 30 hops
    
      1    <1 ms    <1 ms    <1 ms  router [192.168.1.1]
      2     8 ms    19 ms     8 ms  10.52.128.1
      3     9 ms     9 ms    25 ms  ip68-2-2-37.ph.ph.cox.net [68.2.2.37]
      4    25 ms     9 ms    14 ms  mcdlcorc01-pos-0-3-0-0.ph.ph.cox.net [70.169.72.62]
      5    12 ms     9 ms     9 ms  mcdldsrj01-ae2.0.rd.ph.cox.net [70.169.76.225]
      6    47 ms    33 ms    43 ms  paltbprj01-ae0.0.rd.pt.cox.net [68.1.0.234]
      7   239 ms   230 ms   226 ms  pos4-0-1.singapore1.sin.seabone.net [89.221.35.157]
      8   242 ms   227 ms   238 ms  pos4-0-1.singapore1.sin.seabone.net [89.221.35.157]
      9     *        *        *     Request timed out.
     10   226 ms   224 ms   223 ms  202.151.241.181
     11   221 ms   224 ms   225 ms  202.151.241.137
     12   225 ms   225 ms   219 ms  202.151.241.129
     13   224 ms   240 ms   249 ms  bun-eth1.sgbp-pe90e.maxis.net.my [202.151.252.118]
     14     *        *        *     Request timed out.
     15     *        *        *     Request timed out.
     16     *        *        *     Request timed out.
     17     *        *        *     Request timed out.
     18     *        *        *     Request timed out.
     19     *        *        *     Request timed out.
     20     *        *        *     Request timed out.
     21     *        *        *     Request timed out.
     22     *        *        *     Request timed out.
     23     *        *        *     Request timed out.
     24     *        *        *     Request timed out.
     25     *        *        *     Request timed out.
     26     *        *        *     Request timed out.
     27     *        *        *     Request timed out.
     28     *        *        *     Request timed out.
     29     *        *        *     Request timed out.
     30     *        *        *     Request timed out.
    
    Trace complete.
    
  • william chanwilliam chan Posts: 1,326
    edited 2011-09-09 17:54
    Mike G wrote: »
    william chan, is it any quicker when you go through http://www.agaverobotics.com/spinneret/controlpanel.htm?

    The link above works well the first time though I have to refresh the screen to seen the LED changes.
    If the logs show that the response time is slow, can HTTPServer code be changed to allow longer time before timeout?
  • marzec309marzec309 Posts: 146
    edited 2011-09-09 20:15
    Have you thought much about requiring a log in user name and password to access the spinneret?
  • Mike GMike G Posts: 2,702
    edited 2011-09-10 00:18
    If the logs show that the response time is slow, can HTTPServer code be changed to allow longer time before timeout?
    The log only shows your WAN address. I used the Windows tracert 113.210.101.143 command from my PC to test the connection.
    marzec309 wrote:
    Have you thought much about requiring a log in user name and password to access the spinneret?
    Well yes, and I implemented a very basic authentication scheme when uploading a binary to program a second propeller. If the password matches then the user is authorized to upload the file.
  • william chanwilliam chan Posts: 1,326
    edited 2011-09-10 16:42
    Can you pinpoint the problem from the log?
    Access is still difficult from my end but it seems to have improved.
  • Mike GMike G Posts: 2,702
    edited 2011-09-10 17:27
    Can you pinpoint the problem from the log?

    William, I'm not sure how to fix the reported problem. I can't reproduce the problem on my end. However, I can reproduce a large latency and timeouts using the tracert command to your WAN IP. That's why I asked you to hit http://www.agaverobotics.com/spinneret/controlpanel.htm which is a full blown web server. You reported
    The link above works well the first time though I have to refresh the screen to seen the LED changes.

    Refreshing has nothing to do with the issued command. It does indicate a poor video connection. That's two different servers on very separate domains that appear to have the same issue, latency. Add to that the folks that have successfully accessed the tutorial. I'd gladly fix the problem but I have no idea where to start.

    Have you done any troubleshooting on your end? How about connecting a Spinneret on your end?
Sign In or Register to comment.