I recently started playing around with the Windows IoT core and deployed a Universal Windows Platform (UWP) app to my Raspberry Pi (RPi). My UWP app uses HttpClient to make a call to an API so, naturally, an Internet connect was required.
I made (a terrible) assumption that by plugging the Ethernet cable into the Raspberry Pi and into my laptop, it would give it life! … I mean… An Internet connection. I was wrong of course. All that allowed me to do was form a connection between my RPi and my laptop so that I could deploy to it. And so the annoyance of debugging began with me trying to figure out why my app worked when deployed to my laptop, but crashed when it was deployed to the RPi.
I finally did the right thing, the thing I should have done from the beginning. I read the exception errors properly. Then I found that it was a HttpRequestException, which meant it wasn’t connected to the Internet, which meant I was an idiot for A) not checking the exception earlier and B) for assuming an Ethernet connection between the Pi and my laptop = Internet.
I ran around for a bit aimlessly hunting my wireless adapter. Couldn’t find it, great. Then began the process of moving my entire workstation to my router downstairs, which was effort I must admit, but it worked! I plugged the Ethernet cable from the RPi to the router, turned the RPI on, my app launched, I pressed the button, AND I GOT RESULTS! My app worked just as well as it did on my mobile phone, as it did on my computer, as it did on my tablet – it was truly universal, and it worked!
So other than learning Raspberry Pi Ethernet Cable + Computer =/= Internet, I remembered the importance of exception handling.
Moral of the story?
Edit: I have now been informed that you can get Internet on the Raspberry Pi through an Ethernet connection to your PC, you just have to set up/allow the Internet Connection Sharing option. Check it out here.
Thanks Rob 🙂