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.
ContentEncoding: 'HttpResponse.ContentEncoding threw an Exception of type 'System.NullReferenceException'
ContentType: 'HttpResponse.ContentType threw an Exception of type 'System.NullReferenceException'
As far as i understand it the standard HttpWebRequest .net dev's are familiar with, relies on streams to operate, which although technically possible in netmf is very memory intensive and so is either not implemented or max's out the available ram very quickly. However the netmf toolbox http client takes a different approach and has worked very successfully for myself including long-polling scenarios.
As far as i understand it the standard HttpWebRequest .net dev's are familiar with, relies on streams to operate, which although technically possible in netmf is very memory intensive and so is either not implemented or max's out the available ram very quickly. However the netmf toolbox http client takes a different approach and has worked very successfully for myself including long-polling scenarios.
Nak.
Hi Nak,
thank you for your reply.
This toolbox is awesome!
Is it possible to share the URL that you're trying to fetch and full code so I could try to reproduce it? I recently heard about an issue with IIS web servers (http://forums.iis.net/t/1166229.aspx) which want to have the connection established too fast. Could that be the issue?
_remoteSocket = new IntegratedSocket("localhost", 80);
_remoteSession = new HTTP_Client(_remoteSocket);
HTTP_Client.HTTP_Response response = _remoteSession.Get("");
Hi,
For localhost it makes sense, since localhost refers to the Netduino itself, which doesn't listen on port 80. Also a GET request (almost) always starts with a /
My own webserver at www.netmftoolbox.com is optimised to rule things out, and if you request /helloworld/ you'll get a few lines of text. Could you try that out?
For localhost it makes sense, since localhost refers to the Netduino itself, which doesn't listen on port 80.
...this was the problem
I'm porting from a Console Application where, of course, I refer to my IIS using localhost and I forgot this "little" difference between localhost on a PC and localhost on simulator -.-
I assume you are trying to connect to a ASP.Net MVC site from the signalr refference in your URI?
I had some issues with in the past due to incorrect mimetypes, doesnt signalr require a mime of "application/json" or similar?
The easiest way to prove this would be to define a hello world controller, something like this:
using System;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web.Mvc;
namespace testPoll {
public class HomeController : Controller {
public string Index() {
return "Hello World";
}
}
}
That controller should respond to practically anything as long as your request is well formed.
Here is some code that i have used to test the http client with before:
private void testHttpGet(){
var ServerName = "google.com";
var HttpClient webClient = new HttpClient(new IntegratedSocket(ServerName, 80)); }
var response = WebClient.Get("/");
if(response.ResponseCode != 200) {//Something went horribly wrong in the ether
Debug.Print("FARK!!!!");
continue;
}
//HTTP Sucess parse response
if(response.ResponseBody == "\r\n\r\n"){//Empty Response Body Discard
continue;
}
Debug.Print(response.ResponseBody);
}
Damn phone support call at work, looks like a lot happened in the thread whilst i was on phone lol
Glad to hear its sorted now.
Funny that was the issue spent most of yesterday educating one of the Jnr Dev's here about when to use localhost and how machine name is the identifier to rely on, when sending links people for support
@Stefan, is their a use case for adding additional info to the XML comment for Simple socket that entering localhost here means you are connecting to the NETMF Board the client is running on, or similar words to that effect?
Nak.
@Stefan, is their a use case for adding additional info to the XML comment for Simple socket that entering localhost here means you are connecting to the NETMF Board the client is running on, or similar words to that effect?
Nak.
Just for dummies
Now I'm fighting with the CLR_E_OUT_OF_RANGE error at runtime!!!
Maybe the string for the request is too long?
I could use your help. I have been trying to use your HttpClient
all day and can't get it to post to my IIS server and get a response. If you leave your test server in on port 80 it works fine but any other server it does nothing and eventualy I get this error:
"A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll"
When I check the logs on the IIS server it shows no requests being made by the Netduino. I can access the page from any browser with no problem.
Any help is appreciated.
Thank,
Mark
Public Sub PostSmsMsg() Try ' Creates a new web session Dim WebSession As HTTP_Client = New HTTP_Client(New IntegratedSocket("http://XXXXXXXX.no-ip.biz/Twilio/WebSite/smsresponse.aspx", 10343)) ' Requests the latest source Dim Response As HTTP_Client.HTTP_Response = WebSession.Post("") ' Did we get the expected response? (a "200 OK") If Response.ResponseCode <> 200 Then Throw New ApplicationException("Unexpected HTTP response code: " + Response.ResponseCode.ToString()) End If ' Fetches a response header Debug.Print("Current date according to www.netmftoolbox.com: " + Response.ResponseHeader("date")) ' Gets the response as a string Debug.Print(Response.ToString()) Catch ex As Exception Debug.Print(ex.ToString) End Try End Sub
Try removing the HTTP:// part of ur URL, simplesocket does a dns lookup to get the uri's ip address, the HTTP:// part of a URL is used to define protocol, as U are using the HTTP client the HTTP part of the URI is implicit
Hope that helps
Nak.
No worries it catches me out all the time, so used to the httpclient object in .net 4.5 I keep putting HTTP I front of URLs, should probably write a netmf implementation which behaves the same.