Shop OBEX P1 Docs P2 Docs Learn Events
Testing Spinneret Web Server outside of my home network - Page 2 — Parallax Forums

Testing Spinneret Web Server outside of my home network

2»

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-01-07 06:40
    Nice Beau... Thought I would do something similar this weekend if time permits.
  • tonyp12tonyp12 Posts: 1,951
    edited 2011-01-07 12:59
    Have someone made a webcode for the spinneret so it will call out to
    get it's own IP address for Dynamic DNS Services?

    Most routers support it, but it would be also good to have the spinneret doing it directly for itself.

    http://www.no-ip.com/services/managed_dns/free_dynamic_dns.html

    http://www.dyndns.com/services/dns/dyndns/domains.html

    The protocol on how do it:
    http://www.no-ip.com/integrate/
  • Mike GMike G Posts: 2,702
    edited 2011-01-07 14:51
    @tonyp12, yes I can get my ISP assigned IP address. Roy E also made killer DCHP code for the Spinneret.
  • bomberbomber Posts: 297
    edited 2011-06-07 11:16
    I get a "oops" error when I tried to connect.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2011-06-09 14:29
    bomber.... it's been down awhile :-) ... just a test anyway.
  • JeffaJeffa Posts: 80
    edited 2011-07-10 16:57
    Hi Beau

    Thank you for making this available. I've been working on it for my Spinneret project. I added an LED button and have been happily toggling the LED on/off a bit this afternoon. Since the LED is yellow when on I made the button that way too. I have it publicaly available on github https://github.com/jhalbrecht/nerdDoro

    nerdDoro.png


    What are the numbers in the {comments] used for?
    buttons
            byte  "<FORM ACTION='button_action'method='get'>"
        {86}byte  "<BUTTON TYPE='submit' NAME='P24'><FONT COLOR=RED  >P24</FONT></BUTTON>"
        {64}byte  "<BUTTON TYPE='submit' NAME='P25'><FONT COLOR=RED  >P25</FONT></BUTTON>"
        {64}byte  "<BUTTON TYPE='submit' NAME='P26'><FONT COLOR=RED  >P26</FONT></BUTTON>"
        {64}byte  "<BUTTON TYPE='submit' NAME='P27'><FONT COLOR=RED  >P27</FONT></BUTTON>"
       {foo}byte  "<BUTTON TYPE='submit' NAME='P23'><FONT COLOR=RED   >LED</FONT></BUTTON>"
    '                                                           &#61600;&#61600;&#61600;&#61600;&#61600;
            byte  "</FORM>"'          This area is dynamically updated in "PUB SetButtons"
    
    758 x 779 - 140K
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2011-07-11 09:12
    Jeffa,

    The numbers were just a note for me to keep track of an offset during the dynamic html updating that the spinneret perfromed. If you look higer in the code...
        If P24 == 0
           bytemove(@buttons[86+70*0],@RED,5)
        Else
           bytemove(@buttons[86+70*0],@GREEN,5)
    
        If P25 == 0
           bytemove(@buttons[86+70*1],@RED,5)
        Else
           bytemove(@buttons[86+70*1],@GREEN,5)
    
        If P26 == 0
           bytemove(@buttons[86+70*2],@RED,5)
        Else
           bytemove(@buttons[86+70*2],@GREEN,5)
    
        If P27 == 0
           bytemove(@buttons[86+70*3],@RED,5)
        Else
           bytemove(@buttons[86+70*3],@GREEN,5)
    

    The number 86, is the number of bytes from the buttons address before the first "R" of the word RED in the HTML code. Where it says 64 in the HTML code it should actually say 70. This is the amount of offset in BYTES from the first "R" in RED to the first "R" in RED on the next line down. ... It was 64, because the HTML code said something slightly different when I originally wrote it.
  • MoskogMoskog Posts: 554
    edited 2013-01-23 08:55
    Hi, I wonder if there ever was a solution found on the crash-problem issue, (described first time in this thread at post #19). I do have a Spinneret setup based on Beau's code but with even a more simple html-page then in his originally "Spinneret_Web_Server_DEMO v1.2". Just a few html-tags and one single variable that increases for each hit. All the secondary objects are in their original version.
    My spinneret is connected around the clock and LEDs are always blinking. After start up I can usually access the Spinneret for a few hours but never until next morning. Not from outside and not through my internal network. A friend of mine also face the same problem with his Spinneret using the same spin-files. The browser keeps trying to connect but it ends with a timeout. I keep the Spinneret at port 5000 and you can reach it (if I just reset) at la3usa.com:5000
    I can't remember this was a problem when testing Mike's serverbeer-code so I guess there is a bug somewhere in one of the secondary objects in Beau's project.
  • Mike GMike G Posts: 2,702
    edited 2013-01-23 18:53
    I'd have to look at your source code to be sure... The lockups we saw early in Spinneret development were related to, I believe, managing socket state. You must check the socket status as the socket goes through each phase from open to close (see the manual). If the socket gets stuck in CloseWait then then a disconnect, close, and open must be issued.

    Another issue was related to concurrency. One socket has trouble responding to more than one concurrent request. If a single socket is bombarded with many requests the socket can end up in an unexpected state. So again, you must monitor socket state and execute appropriate logic.

    I've had a Spinneret running HttpServer for well over a year without a lockup.
  • MoskogMoskog Posts: 554
    edited 2013-01-24 07:54
    Hi Mike, I attached my sourcecode if you would like to take a look. The html is taken from a running PINK and contains some dead Nb_vars. I can't imagine that there is a concurrency problem, the spinneret has not faced much requests other then from myself. But there is a chance that could be a problem once the project is finished and the spinneret is permanently online.
    When I used your testcode the spinneret never got stuck but it does with this code.
    My problem is I am too much of a newbee on this Wiznet-stuff so I really need some advices here to be able to really understand how things works.
  • Mike GMike G Posts: 2,702
    edited 2013-01-25 06:56
    Moskog, the follwoing line of code can be a problem.
    repeat while !W5100.SocketTCPestablished(0)

    This code assumes the socket is in a particular state but the state is not checked. If the socket is Closed or CloseWait the repeat will loop forever.

    I wrote a new driver and libraries for the Spinneret. The Html5Graph is more like what you are doing; no SD card or RTC interface. The WebServer_W5100.spin is a basic web server with SD and RTC support.
  • MoskogMoskog Posts: 554
    edited 2013-01-29 13:06
    Ok, thanks.
    The html5graph looks very interesting. I suppose my own setting like subnetmask, ip, mac and gateway should be set by replacing the empty numbers in the DAT section of W5100 object, right?
    But where do I set my port number (e.g. 5000)?
    And do I then call the spinneret with the browser by typing 10.0.0.190:5000/index.htm?
  • Mike GMike G Posts: 2,702
    edited 2013-01-29 13:54
    Line 144 initializes the socket and port.
    sock[i].Init(i, TCP, 8080)
    
    Html5Graph uses DHCP so just watch the PST screen for the assigned IP. You can request a specific IP by invoking the dhcp.SetRequestIp(192, 168, 1, 110). However, the IP must be available otherwise DHCP will assign the IP.

    Example:
      pst.str(string("Getting network paramters", CR))
      dhcp.SetRequestIp(192, 168, 1, 110)
      dhcp.Init(@buff, DHCP_SOCKET)
      pst.str(string("Requesting IP....."))
    
  • MoskogMoskog Posts: 554
    edited 2013-01-30 13:19
    Ok, now it seems like it works.
    The strange thing is that even though I tried to give it the original IP number 10.0.0.190 it kept renumber it to 10.0.0.186.
    So the next thing to try was to set the IP to 10.0.0.186 and also replace the Virtual server configuration in the router with the same number (for the outside access) and that also worked. At least for tonight.
    You say it will try to find another IP in case the original number is not available, I wonder why the Spinneret's original IP wasn't available no more, all the other devices on my network has fixed IP numbers, it should still be available.
    But 10.0.0.186 is good enough as long as it does not change it.
    Spinneret should now be seen at la3usa.com:5000

    Thanks again, I really do appreciate your help!

    Edit: Well, ten minutes later the IP address has changed again, now it is 10.0.0.187
    Any idea on this new dynamic IP address issue?
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-01-30 13:38
    Moskog,

    I used this snippet to manually set the IP and other addresses. I have two spinnerets, one for testing and one that's deployed in the chicken coop. I just select the one I need and comment out the other. Don't know if you'll need that, so just ignore the extra set of Mac and IP commands. :D
    wiz.HardReset(RESET_PIN)
    
    { =======================  select deployed or test spinneret ============================== }
    'deployed spinneret
    '  wiz.SetMac($00, $08, $DC, $16, $F3, $25)
    '  wiz.SetIp($61, $0A, $0B, $FE)                 'deployed unit
                                                     '97.10.11.254
    'test spinneret   
      wiz.SetMac($00, $08, $DC, $16, $F2, $1A)     'test unit
      wiz.SetIp($61, $0A, $0B, $FD)                '97.10.11.253       
    'dont forget to adjust GetValues Method 
    'common to both units
      wiz.SetGateway($61, $0A, $0B, $01)          
      wiz.SetSubnetMask($FF, $FF, $FF, $00)
      wiz.CopyDNS(@dns_addr, 4)
    {===========================================================================================}
    

    Then comment out the DHCP code:
    pst.str(string("Getting network paramters", CR))
    {  
    -- comment out or delete --
    
    dhcp.Init(@buff, DHCP_SOCKET)
      pst.str(string("Requesting IP....."))
    
      repeat until dhcp.DoDhcp(false)
        if(++i > DHCP_ATTEMPTS)
          quit
    
      if(dhcp.GetErrorCode > 0 OR i > DHCP_ATTEMPTS)
        pst.char(CR) 
        pst.str(string(CR, "DHCP Attempts: "))
        pst.dec(i)
        pst.str(string(CR, "Error Code: "))
        pst.dec(dhcp.GetErrorCode)
        pst.char(CR)
        pst.str(dhcp.GetErrorMessage)
        pst.char(CR)
        return
        
      else
    }
        PrintIp(wiz.GetIp)
    

    Then change this:
    PrintIp(dhcp.GetIp)
    
    to this:
    PrintIp(wiz.GetIp)
    
  • MoskogMoskog Posts: 554
    edited 2013-01-30 13:57
    Thanks Doggidoc I will give it a try tomorrow and let you know. It is midnight here in an hour so I should rather go to sleep.

    Beside of that, I checked your Doc's Flock- project earlier and that looks awesome!
  • Mike GMike G Posts: 2,702
    edited 2013-01-30 18:34
    Moskog, the DHCP object does not assign the IP address, your router does. The DHCP simply makes a request.
  • MoskogMoskog Posts: 554
    edited 2013-01-31 12:50
    OK, I'm back on the track again and the Spinneret is up and running with its origial, static IP number. I loaded in the PINK html-file for testing, with empty values so far, but now I think I have something to continue from.

    Thanks again, Mike G and Doggidoc!


    http://la3usa.com:5000/
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-01-31 18:21
    Looks good Moskog! It loaded fast and with no problems.
Sign In or Register to comment.