I’m attempting to connect a Spider to Azure in order to push pictures into blob storage. I’m using a snippet of code that I found in MSDN magazine a few months back. Here is the code that is throwing the error:
Int32 picLength = blobContent.Length;
WebRequest putPhotoRequest = WebRequest.Create(sasUrl);
putPhotoRequest.Method = "PUT";
putPhotoRequest.Headers.Add("x-ms-blob-type", "BlockBlob");
putPhotoRequest.ContentLength = picLength;
Debug.Print("Attempting Upload");
try
{
Debug.Print("Writing to Stream");
using (Stream requestStream = putPhotoRequest.GetRequestStream())
{
requestStream.Write(blobContent, 0, blobContent.Length);
requestStream.Close();
}
Debug.Print("Getting Response");
using (HttpWebResponse response = (HttpWebResponse)putPhotoRequest.GetResponse())
{
Debug.Print("HttpWebResponse.StatusCode: " + response.StatusCode.ToString());
Debug.Print("HttpWebResponse.StatusCode: " + response.StatusDescription.ToString());
}
}
catch (Exception e)
{
Debug.Print("An error occured." + e.Message);
}
Everything seems to be working fine, up until the point it performs the requestStream.Write(). Once it hits that code, it throws the following error:
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] ####
#### GadgeteerCamera4.AzureBlob::PutBlobMobile [IP: 0101] ####
#### GadgeteerCamera4.Program::insertImageintoAzureBlob [IP: 0020] ####
#### GadgeteerCamera4.Program::camera_PictureCaptured [IP: 0044] ####
#### Gadgeteer.Modules.GHIElectronics.Camera::OnPictureCaptured [IP: 0036] ####
#### System.Reflection.MethodBase::Invoke [IP: 0000] ####
#### Gadgeteer.Program::DoOperation [IP: 001a] ####
#### 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 = 10040
#### SocketException ErrorCode = 10040
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10040
#### SocketException ErrorCode = 10040
An error occured.Exception was thrown: System.Net.Sockets.SocketException
Has anyone run across this before? I’ve tried a couple of things based on some other web searches, but nothing has worked so far.
Any help is greatly appreciated.