Can't get any HTTP client examples working on 2368

09 Jun 2011

I recently received my mbed (2368) and was really excited about using the ethernet port to talk directly to the internet. I've migrated over from PICs, although I have used Arduino library-based code in the past.

My problem is that no matter which HTTP client examples I use, I can't seem to receive any data from any website/url.

From http://mbed.org/users/segundo/programs/NetServices_HelloWorld/ljh122 to http://mbed.org/users/donatien/programs/HTTPClient/5ydi1, and all the other HTTPClient examples inbetween, all of the examples connect to my router, get an IP address from the DHCP, write messages to the terminal window etc. But whenever this line is encountered: HTTPResult r = http.get("http://mbed.org/media/uploads/donatien/hello.txt", &txt);

the device seems to lock up. No error messages, no timeouts, nothing! It just sits there for 10-15 minutes (or until I get fed up and re-boot it) and refuses to return any data.

What is particularly frustrating is that my friend is running the 1768 board and he can run all the examples perfectly without a problem. We've tried running the same projects on the two different boards at my house, his house, and down at our nerd club, and each time the result is the same - his 1768 returns data almost immediately following the .get command; my 2368 board appears to lock up. We're sharing an RJ45 socket on a breakout board, so I'm sure it's not the hardware nor the router set-up.

I'm sure I'm missing something really simple. Anyone any ideas? It's driving me mad!!

10 Jun 2011

Here's a development: I managed to get the Twitter type example working, but only sporadically. Instead of using HTTP GET this example uses HTTP POST. I changed the URL in the code to different addresses and suddenly started getting a response - HTML written to the terminal window.

But the frustrating thing is that this still only works about 1 time in 5 attempts. If I reset the mBed board, the code runs to the point of getting an IP address, writing it to the terminal window, but then still getting stuck at the HTTP GET (or HTTP POST) command.

After restarting the device a few times (or sometimes even disconnecting the entire device and leaving it for a few minutes) occasionally the code gets past the GET command and actually returns the contents of the web page to the terminal window. But on the next attempt, it locks up!

I'm desperate to get a robust, working HTTP client but at the minute, mine seems just a bit flaky! I even went out and bought the [ http://mbed.org/blog/entry/mbed-Breakout-Board-and-Starter-Kits1/ ]mBed breakout board just in case my soldering on the RJ45 socket was a bit dodgy (although the same socket works perfectly for my mate who has a 1768 board). Is there a problem with running an HTTP client on a 2368 board?

For me, an intermittent problem is worse than getting no response at all - because I can see that sometimes it works! Exactly the same code (on the chip) calling exactly the same web page - sometimes is works, most times not. I can't puzzle out what conditions stop it from working about 80% of the time....