Iām running the following using SDK 4.3:
public void TransmitValue(string json)
{
using (var request = HttpWebRequest.Create(_postUri))
{
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = json.Length;
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(json);
streamWriter.Flush();
}
}
}
The line containing ārequest.GetRequestStream()ā is the one that explodes into this:
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::send [IP: 0000] ####
#### System.Net.Sockets.Socket::Send [IP: 0018] ####
#### System.Net.Sockets.NetworkStream::Write [IP: 0051] ####
#### System.Net.InputNetworkStreamWrapper::Write [IP: 000a] ####
#### System.Net.HttpWebRequest::SubmitRequest [IP: 007d] ####
#### System.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
#### CareForPlant.Program::OnTimerTick [IP: 0046] ####
#### Gadgeteer.Timer::dt_Tick [IP: 0018] ####
#### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 001d] ####
#### SocketException ErrorCode = 10054
#### SocketException ErrorCode = 10054
#### SocketException ErrorCode = 10054
#### SocketException ErrorCode = 10054
#### SocketException ErrorCode = 10054
Exception thrown: 'System.Net.Sockets.SocketException' in System.Http.dll
#### SocketException ErrorCode = 10054
An exception of type 'System.Net.Sockets.SocketException' occurred in System.Http.dll but was not handled in user code
#### SocketException ErrorCode = 10054
Exception performing Timer operation
The program '[5] Micro Framework application: Managed' has exited with code 0 (0x0).
I found a similar post but saw no solution to it. I have initialized the network beforehand using this:
public void InitializeNetwork()
{
_display.Clear();
_display.Print("Connecting...");
_network = new EthernetENC28(4);
_network.NetworkInterface.Open();
_network.NetworkInterface.EnableDhcp();
_network.NetworkInterface.EnableDynamicDns();
Thread.Sleep(250);
if (!_network.NetworkInterface.CableConnected)
{
_display.Print("No cable!", 1);
}
while (_network.NetworkInterface.IPAddress == "0.0.0.0")
{
Thread.Sleep(250);
}
_display.Print("Net: " + _network.NetworkInterface.IPAddress, 1);
Thread.Sleep(2000);
}
I need ideas for what I may be doing wrong