Shop OBEX P1 Docs P2 Docs Learn Events
Problematic page loading — Parallax Forums

Problematic page loading

WildatheartWildatheart Posts: 195
edited 2013-01-28 19:39 in Accessories
HTML code is written (in part) to display a jpg on web page. Sometimes it loads the full jpg, sometimes part of the jpg, and sometimes the jpg doesn't load at all. Although the code does indeed work as intended, the full display is very problematic using IE and less problematic when using iphone (safari). Most of the time the situation can be resolved if another image at http://blahblah is referenced in place of the jpg.

On another matter, I have working code to load and display google maps but I'd like to use 'earth in place in place of 'maps. The code for 'earth can be found at http://code.google.com/apis/ajax/playground/?exp=earth#draggable_placemark . I'd be grateful if someone can help me with the header code to load this API.

Comments

  • Mike GMike G Posts: 2,702
    edited 2013-01-25 11:58
    What code are you using and how large is the jpg? There could be a bug in the new Spinneret web server library that causes this behavior. It's been fixed but not uploaded to the repo. If this is for the W5200, get the latest.
    On another matter, I have working code to load and display google maps but I'd like to use 'earth in place in place of 'maps. The code for 'earth can be found at http://code.google.com/apis/ajax/playground/?exp=earth#draggable_placemark . I'd be grateful if someone can help me with the header code to load this API.
    Are you trying to run this from a Spinneret or W5200?
  • WildatheartWildatheart Posts: 195
    edited 2013-01-25 13:53
    Thanks for looking, Mike. jpg is 164k

    I'm using the W5100 on the original Spinneret board. The code date is August 1012.
  • WildatheartWildatheart Posts: 195
    edited 2013-01-25 14:24
    The page in question can be found at http://www.sedonapaws.com/

    When making changes to the SD card, and after reinserting it, I reset both the Spinneret and the Prop. It typically takes 2 pings to get any activity displayed in the web page.

    If the jpg doesn't load, nor does the google map.
  • Mike GMike G Posts: 2,702
    edited 2013-01-25 17:48
    I attached the new code to New Drivers for the Spinneret. The best place to grab the latest stuff is Google Code. I realize it is a pain in the butt downloading code with a browser but it does contain the latest code and bug fixes. i do not plan to continually update the forum attachments as it's too hard after time passes.

    Please zip and post the HTML.
  • LtechLtech Posts: 380
    edited 2013-01-26 04:10
    line 232 in new webserver from google code => mtuBuff := sock[id].GetMtu
    and
    line 403 => pst.dec(sock.GetTtl)

    GetMtu & GetTtl are nod defined ....

    Thanks
  • Mike GMike G Posts: 2,702
    edited 2013-01-26 04:51
    Ltech, there are 3 main file for the Spinneret; Spi5100CounterPasm.spin, W5100.spin and Socket.spin. You must download all the latest files from the repo not just the web server.

    The right side of the download page shows the date files were updated. It's a good idea to always get the latest stuff. the change log can be viewed by clicking the file name.
  • WildatheartWildatheart Posts: 195
    edited 2013-01-26 19:46
    I traded the new Linksys/Cisco N750 for a new Linksys/Cisco EA4500 believing that bigger is better. It didn’t solve any problems and perhaps created more problems. So… I loaded an old copy (known to work) of httpServer and a very simple HTML index.htm file that essentially displays 3 iterations of “Hello World”. The page displayed as expected at 192.168.1.126:5000 but the Spinneret would not ping at “my IP address:5000”.

    I called Linksys/Cisco tech support and they took control of my laptop and checked settings. Turns out that the new routers are programmed to reject their own IP address if called within the network. Turning off the WiFi connection on my iPhone allowed me to access “my IP address:5000”. It seems that this security feature was not available on the older routers.

    Knowing that, and knowing that my router was properly set to recognize “my IP address:5000” from outside of the local network and from 192.168.1.126:5000 withing the local network, I downloaded each of the latest Google files for the w5100.

    The folder containing those files is attached. Because the Spinneret is now not accessable locally or from the outside, I think the place to start is to ask for a review of my changes I made in w5100.spin and in WebServer_5100.

    My current IP is 72.222.215.152.

    Will attach the originally requested HTML5 file after I can get “Hello World” up and running.
  • WildatheartWildatheart Posts: 195
    edited 2013-01-27 04:19
    Cleared all files and reloaded all of the latest W5100 files from Google again this morning. "Hello World" ran perfectly on the first attempt - on both, my LAN and from my IP address in the outside world. I then reloaded the original index.htm (attached) and am experiencing the same problematic effects first described.

    If the problematic matter can be resolved I'd still like help to replace the Google map API with the Google Earth API found at
    http://code.google.com/apis/ajax/playground/?exp=earth#draggable_placemark

    Existing can be found at http://72.222.215.152:5000
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-01-27 04:38
    Hey Wildatheart - I haven't had a chance to look at your code yet but I think some of my problems were related to what services I was allowing on the port I was forwarding to the Spinneret. Originally I was allowing UDP and TCP - wasn't sure about the UDP so I allowed it anyway. I have disallowed UDP now and with just TCP on the port, it seems to be more stable. Don't know if this helps but thought I'd mention it.

    Doc
  • LtechLtech Posts: 380
    edited 2013-01-27 06:10
    Sorry, I fond it.
    I was to fast !
    Is there a way to get them all at once ?

    Thanks a lot for your code
  • Mike GMike G Posts: 2,702
    edited 2013-01-27 10:05
    Wildatheart, I dropped the site on my SD card it - just worked. Hopefully someone can verify...
    http://spinneret.servebeer.com:8080/

    I looked specifically at the logo.jpg file and found malformed packet errors related to the IPA protocol. It may be nothing but the packets are not formatted as I expect or have experienced during development. At first, it looked as though the packets are coming from a GSM network; cell phone. Anyway, there are dropped packets and the connection does not appear to recover. The jpg always stops after sending 113951 of 168061 bytes. It could be the Socket is sending data to quickly but it's a little weird the error always happens at the same spot in the download process.

    This is what what I suggest we do...
    • Use a smaller jpg which is attached (500x347 28k). You really want to use the smallest files possible. The Spinneret, by default, is sending the files in 1460 byte chunks. The less packets to send the better.
    • Add a pause in the RenderFile loop.
    • Format the SD card and re-drop the files. Sometimes the FAT driver messes up the files and we get weird results.
    • We might have to decrease the send buffer to something less than 1460.

    Added Pause...
    PRI RenderFile(id, fn) | fs, bytes
    {{
      Render a static file from the SD Card
    }}
      mtuBuff := sock[id].GetMtu
    
      OpenFile(fn)
      fs := sd.getFileSize 
      BuildAndSendHeader(id, fs)
    
      'pst.str(string(cr,"Render File",cr))
      repeat until fs =< 0
       ' Writeline(string("Bytes Left"), fs)
    
        if(fs < mtuBuff)
          bytes := fs
        else
          bytes := mtuBuff
    
        sd.readFromFile(@buff, bytes)
        fs -= sock[id].Send(@buff, bytes)
    
        'Pause after issuing the send command
        pause(10)
      
      sd.closeFile
      return
        
    
    500 x 347 - 28K
  • WildatheartWildatheart Posts: 195
    edited 2013-01-27 10:25
    Yikes! It worked on all 3 attempts on your site.

    From my end, I added a first time observed weird load of the jpg (attached) - might shed light on the matter.

    Will make changes as you suggest this morning. Thanks, Mike!

    @doggiedoc disabled UDP as you suggest and it may have marginally improved the LAN loading. Yesterday, Cisco advised keeping the setting at both, TCP and UDP, however, another tech told me disable UDP for security reasons? Not sure, but don't think that's the answer to our problematic loadings.
  • WildatheartWildatheart Posts: 195
    edited 2013-01-27 10:36
    After several more tries... many good loads, some blank pages, and some no load of the jpg at all.
  • WildatheartWildatheart Posts: 195
    edited 2013-01-27 10:44
    Ltech wrote: »
    Sorry, I fond it.
    I was to fast !
    Is there a way to get them all at once ?

    Thanks a lot for your code


    '...them all at once?" If you're referring to the W5100 files posted on Google, I think not. I think its a copy and paste of each file.
  • WildatheartWildatheart Posts: 195
    edited 2013-01-27 11:50
    Reduced size of logo.jpg.
    Reformatted SD card.
    Added pause.

    Results... better but remain problematic. Results now similar to servebeer server.
    Safari and IE - equally problematic.

    http://72.222.215.152:5000
  • MoskogMoskog Posts: 554
    edited 2013-01-27 12:28
    Wildatheart

    Can only get one third of the picture, only see the top of the mountain.
    On servebeer I could load the whole pic.

    Also need to load your page twice because I always get an error page when first time loading.
  • Mike GMike G Posts: 2,702
    edited 2013-01-27 13:08
    Try replacing the existing timeout logic in the MultiSocketService method with the following snippet and see if that helps.
        'Check for a timeout error
        if(bytesToRead =< 0)
          pst.str(string(CR, "Timeout: "))
          pst.dec(bytesToRead) 
          PrintAllStatuses
          if(i++ == 1)
            sock[sockId].Disconnect
            i := 0    
          next
    


    We might need to add a pause in the main repeat loop.
        'Display the request header
        'pst.str(@buff)
        pause(10)
    
  • WildatheartWildatheart Posts: 195
    edited 2013-01-27 13:54
    Made both changes.

    Results... Some good loads. Some loads with no jpg. And some loads with blank screen. But so far no partial jpg loads as before.

    See attached screenshot for a previously unseen load. Can this possibly be bad HTML code? Don't think so because this is first time showing, but I am a newbe to HTML.

    servebeer site seems more stable

    Edit: iPhone on 3G displays white screen without a reset. After a reset 3G hangs mid jpg load.

    Can't take a screenshot of iPhone display but *** it just displayed the actual HTML text *** at a point beginning well into the code, then to the end of the code text - no graphics at all. YIKES!

    Could it be the servebeer server (possibly w5200) is upgraded from the original Spinneret?
  • Mike GMike G Posts: 2,702
    edited 2013-01-27 16:33
    I took a closer look at the HTML source... You've got a lot going on. The Index page over 22k. That's 15 SD card reads and 15 Socket sends not including header overhead.

    I went ahead and removed a lot of the redundant CSS, 11k worth, and attached the much smaller jpg and index.htm page.
    servebeer site seems more stable
    It's probably because my ISP upload is pretty darn quick. With that in mind, add a pause is between the Socket.Connected and Socket.Available method as shown below. I'm guessing the socket is connected but the data (HTTP request header) has not been received. Go ahead and mess around with the pause value and let us know how it works out; if it works at all.
        'Cycle through the sockets one at a time
        'looking for a connections
        repeat until sock[sockId].Connected
          sockId := ++sockId // SOCKETS
    
        pause(20)
        
        'Repeat until we have data in the buffer
        repeat until bytesToRead := sock[sockId].Available
    

    If the request is timing out you should see a timeout message on the Parallax Serial Terminal that looks like the following, right?.
    Timeout: -1
    Socket Status
    0   1   2
    00  17  14
    

    The timeout code I posted earlier is not correct... use this snippet. Plus you'll have to add i as a local variable and set it 0 when the MultiSocketService starts up. I forgot to add that info... sorry.
    PRI MultiSocketService | bytesToRead, sockId, fn, i
      bytesToRead := sockId := 0
      i := 0
    ...
    'Check for a timeout error
        if(bytesToRead =< 0)
          pst.str(string(CR, "Timeout: "))
          pst.dec(bytesToRead) 
          PrintAllStatuses
          if(i++ == 1)
            sock[sockId].Disconnect
            i := 0    
          next
    
  • WildatheartWildatheart Posts: 195
    edited 2013-01-27 18:45
    WOW! After seeing your cleanup of my index html code I now know where servebeer comes from - I (we) definately need to serve you one!

    Made suggested changes... http://72.222.215.152:5000 now functions at about 95% in IE on my laptop. Access with my iPhone on 3G is nearly impossible - I get nothing, else I received the partial HTML text again.

    Will experiment with the delay settings after a bit.

    Enclosed is the HTML Google Earth code. If you have time would you please substitute it for maps in my index.

    Hopefully these changes will benefit the sporadic loading doggiedoc was experiencing and others as well. I'm sure we'll generate a lot of interest to see some fancy CSS and some chicken coops running on the Spinneret.
  • Mike GMike G Posts: 2,702
    edited 2013-01-27 19:00
    Hey doggiedoc, feedback would be most appreciated. Are you still experiencing problems with the code?

    Wildatheart, I've been hitting the site pretty hard but it seems to recover well... I'll get a "page cannot be displayed" or "unable to connect" but a refresh and boom there it is...
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-01-27 19:28
    Mike I was planning to adapt my code to use HTTPServer first. I've been using Beau Schwabe's Demo as a starting point. I think I've learned enough now to accomplish the same thing with HTTPServer. I just couldn't figure out how to get my sensor data to the webpage with HTTPServer. I'll start a new thread after I experiment some more.

    Sorry for the HiJack Wildatheart.
  • Mike GMike G Posts: 2,702
    edited 2013-01-28 08:41
    doggiedoc, nothing wrong with HttpServer, it works great. The Spinneret that serves the HttpServer tutorial has been up for over a year without a lockup.

    But... Can I convince you to make the jump to the new code base? The new WizNet code is designed to share libraries between the W5200 and Spinneret. Plus, I'm not thrilled to support two different code bases; HttpServer and the layered socket/interface approach. It just occurred to me, I should to come up with a name for the new code... hummm.

    Either way you'll have my support. Let me know if you need anything.

    Wildatheart, site is still up and running I see.
  • WildatheartWildatheart Posts: 195
    edited 2013-01-28 08:43
    Mike G wrote: »
        'Cycle through the sockets one at a time
        'looking for a connections
        repeat until sock[sockId].Connected
          sockId := ++sockId // SOCKETS
    
        pause(20)
        
        'Repeat until we have data in the buffer
        repeat until bytesToRead := sock[sockId].Available
    

    If the request is timing out you should see a timeout message on the Parallax Serial Terminal that looks like the following, right?.
    Timeout: -1
    Socket Status
    0   1   2
    00  17  14
    

    QUOTE]

    Mike, I ran with pause(5) to pause(80) and received timeouts as shown all the way through. Sometimes it was 1 timeout and sometimes it was 4. In any case, the page always appeared and functioned as a full page. iphone on 3G also appears to load the page.

    FYI - I managed to get Google Earth to load last night. Flew around a little but at close zoom values Earth was seemingly out of focus. Tried it again this morning - got the site to load, but it seemed Google wasn't doing its part to connect. They asked for a refresh but that just seemed to lock up. I was hoping that it would snap to, as does 'Maps.
  • WildatheartWildatheart Posts: 195
    edited 2013-01-28 09:14
    doggiedoc wrote: »

    Sorry for the HiJack Wildatheart.

    doggiedoc, you didn't HiJack anything - we're all headed in the same direction here, but thanks for your consideration.

    I too had some experience with HTTPServer last year, and it worked well. But as Mike suggested, we could do a better job of supporting his efforts and the community if we can all get on the same page. The worst of the transition is the copy and paste process from the Google code site.

    http://72.222.215.152:5000 is mostly up and seemingly stable unless I'm tinkering with the code. Check out some of the fun CSS stuff displayed there. You could zoom in and display a Google map that shows your chicken coup - heck, you could even give the fox directions there!
  • WildatheartWildatheart Posts: 195
    edited 2013-01-28 15:17
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-01-28 15:43
    Mike G - I don't mind using the new code base at all. Beau's code was easier for me to figure out how to display the sensor values. I'll download the new code base and get started. I've gone through the tutorial once on servebeer. Does the tutorial still apply to the new code base?

    Thanks!

    Doc
  • Mike GMike G Posts: 2,702
    edited 2013-01-28 19:39
    Does the tutorial still apply to the new code base?
    Yes, the same concepts apply. I redid the Request object and called it HttpHeader. HttpHeader is much smaller and quicker.

    See the Html5Graph for an example of reading real-time data.
Sign In or Register to comment.