Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Experimental Webserver Problem

tcp/ip http html web server

  • Please log in to reply
9 replies to this topic

#1 martin2250

martin2250

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts
  • LocationGermany

Posted 10 February 2013 - 10:41 AM

 

hi guys,

 

I made an experimental HttpServer, and so far it seems to be working, but I have one Problem which I can't solve without some help:

the Program only works when it is launched directly from Visual Studio, even if I attatch MFDeploy as Debugger and reboot the CLR, it only downloads the Current Date/Time and does not respond to any interaction via Ethernet.

 

Since I plan on using this Library for some other things as well, I'd be really happy if you could help me out.

 

If you are interested in my  Http Library for own use, or maybe want to help me find the Problem, i attatched the Library and the Application which implements it at the bottom of this post.

 

Thanks for your time, 

Martin

Attached Files



#2 MarkNic

MarkNic

    Member

  • Members
  • PipPip
  • 22 posts

Posted 11 February 2013 - 04:38 PM

Martin,

 

It appears to be a timing issue.  The reason it works in the VS debugger is probably because debugging is a cpu/time consuming set of operations and things in threads were getting done.  When you switch to the board alone, the delays aren't there and objects are being torn down before they are done responding.  Specifically, the response stream looks like it is being disposed of prematurely.  I was able to get it to fail on the code that was attempting to write to that stream.

 

I can get it to work fairly consistently by placing Thread.Sleep(20); right after you create your thread and start it up.  With that in place I could get it to respond on the board as well.  There are still times where the browser says no data came back but if you refresh it should show a response.  Also, it isn't throwing an exception so it keeps going.

 

I think you have a place to start that will let you test on the board but there's still a couple things that need to be figured out.  One big suggestion I have is to start using the "using" command on objects with a disposable/close interface such as sockets and streams.  With "using" you won't have to deal with closing/disposing and the GC.

 

BTW, I hardcoded the creation of the DateTime just for debugging purposes.

 

I've attached the app with the code that I updated.  Hope this helps,

 

Mark

 

Attached Files



#3 martin2250

martin2250

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts
  • LocationGermany

Posted 11 February 2013 - 06:54 PM

hi Mark,

 

thank you for taking the time to fix the problem, but it still doesn't work (for me at least).

 

strangely, it doesn't even respond to a request, even when changing Thread.Sleep(20) to 2 seconds of delay, so maybe there's some other error. At the moment I can't debug, but tomorrow i'll try to get it working

 

Martin



#4 MarkNic

MarkNic

    Member

  • Members
  • PipPip
  • 22 posts

Posted 12 February 2013 - 03:56 AM

Did you try the code I posted?  It had some other changes in it.  Most had to do with disposing of the object correctly.

 

Mark



#5 martin2250

martin2250

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts
  • LocationGermany

Posted 12 February 2013 - 10:59 AM

Yes, I tried your code and I modified my code without all changes regarding disposing. Both did not work without being launched from VS directly.

 

also it might not only be a problem of timing, since it didn't work after attatching a debugger manually and restarting the application.

 

Martin



#6 martin2250

martin2250

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts
  • LocationGermany

Posted 13 February 2013 - 09:21 AM

ok, I got it to work now :D

it was probably an issue with my SD card, Thread.Sleep(20); did the job

 

thanks,

 

Martin



#7 MarkNic

MarkNic

    Member

  • Members
  • PipPip
  • 22 posts

Posted 13 February 2013 - 03:18 PM

Good to know.  I did test it against content on my SD card and it did a good job of listing the files, folders and even the content of the file when selected.  That is great functionality for an app directly as well as debugging (seeing into files on the SD card without removing it and putting it into a PC).

 

Mark



#8 sebswed

sebswed

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSweden

Posted 17 April 2013 - 07:23 PM

Hello Martin.

 

Short question. On which line should I insert the "Thread.Sleep(20);"?

 

Kind regards,

Sebastiaan


Netduino Plus 2 (v4.2.2.2)


#9 martin2250

martin2250

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts
  • LocationGermany

Posted 18 April 2013 - 06:37 PM

I think it was after line 27 in Request.cs



#10 sebswed

sebswed

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSweden

Posted 19 April 2013 - 03:58 AM

Thanks :)


Netduino Plus 2 (v4.2.2.2)






Also tagged with one or more of these keywords: tcp/ip, http, html, web, server

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.