Main Site Documentation

Dpws client to wcf web-service


#1

Hi I’am working on a client to communicate with a wcf webservice. Basicly all is working with the emulator :-), but when I download it to my EMX-Dev Board I get following error:

[quote] #### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::setsockopt [IP: 0000] ####
#### System.Net.Sockets.Socket::SetSocketOption [IP: 0012] ####
#### Ws.Services.Binding.UdpTransportBindingElement::OnOpen [IP: 00ae] ####
#### Ws.Services.Binding.BindingElement::Open [IP: 0015] ####
#### Ws.Services.Binding.BindingElement::Open [IP: 000f] ####
#### Ws.Services.Binding.ReplyChannel::Open [IP: 0012] ####
#### Dpws.Client.DpwsClient::.ctor [IP: 0077] ####
#### tempuri.org.IPowerContractClientProxy::.ctor [IP: 000b] ####
#### Pps.NETMF.Power.Program::Main [IP: 00cc] ####
#### SocketException ErrorCode = 10049
#### SocketException ErrorCode = 10049
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10049
An unhandled exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
[/quote]

I have googled, but nobody realy knows how to fix this error.

Maybe somewone has a example code to establish a connection with dpws. I have also looked at the sample code of the SDK but it isn’t working, same error.

µC Version: latest 4.2
wcf webservice: .net 4.0

I use ethernet to connect the devices, with a dhcp server.

Best regards


#2

Is it possible that in version 4.2 there is no support of multicast udp messages?


#3

Did you use MFSvcUtil to generate your classes, ot did you build them yourselves ?


#4

I used MFSvcUtil!

The Problem musst be in Framework or the Porting Librarys, because the Demo Programms of the SDK for dpws doesn’t work either.

The hole thing works with the emulator, till Í but it on the emx it crashes.


#5

You have to notice that in certain cases, the MFSCVUTIL makes somes mistakes in the way it parses your class and creates the proxy ! I had some similar errors when using classes as params or returned values.

Can you provide us with your proxy and contract implementation, so that we will probably see what goes wrong…


#6

Here is a list of NETMF socket error code:
http://wiki.tinyclr.com/index.php?title=Lwip_errorcode

So the error code you got 10049 is SOCK_EADDRNOTAVAIL


#7

I don’t think you will be able to get this working on framework 4.2 until UDP is fixed (The readme lists UDP as not working). DPWS uses UDP to broadcast the service and in this case the socket is complaining of an invalid IP address (ErrorCode = 10049). I tried for most of a day to work around this, settign teh IP address and tracing it to make sure it was set correctly. Downgrading to 4.1 was an instant fix.


#8

@ NickP -

I’ll port my 4.1 DPWS implementation to the 4.2 and make some tests in the following days.

I hope 4.2 is not the source of this problem, because in this case it would be a regression and what a big one…


#9

For reference, the 4.1 samples require you to set an IP address before you start the device otherwise you will get the exact same 10049 error in this case because the IP address really is invalid. I added the following to main:

static void Main(string[] args)
        {
      
            var network = NetworkInterface.GetAllNetworkInterfaces()[0];
                        if (!network.IsDhcpEnabled)
                            network.EnableDhcp();
            network.RenewDhcpLease();

With 4.2. the 10049 is being thrown even when the ipaddress is correctly set because the UDP socket is not bound.


#10

UDP problem was fixed and will be in next SDK coming in few weeks.


#11

AWESOME!

Any chance you could use the 4.2 SimpleService sample as part of the test suite? I’m happy to test a pre-release / beta if that helps.


#12

I forwarded this request to the team.


#13

@ Gus - I’ve been trying to get the DPWS sample app to work, and have encountered the same errors as posted here. Can you confirm that these errors are due to the UDP bug?

Thanks.


#14

We didn’t get that far yet but we know that udp didn’t work is now fixed internally so we/you will be able to test very soon. We still have couple priority items.


#15

Ok, thanks Gus.


#16

I downloaded the update but the same issues exist. I.e. just adding a reference to MFDpwsDevice causes the exception below. I guess it is back to 4.1 which is annoying as 4.1 doesn’t send announcements.

if you want to test it is not hard to reproduce, just drag a j11d module on to the designer and add a reference MFDpwsDevice.

'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\MFDpwsDevice.dll', Symbols loaded.
    #### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (2) ####
    #### Message: 
    #### Microsoft.SPOT.Net.SocketNative::getaddrinfo [IP: 0000] ####
    #### System.Net.Dns::GetHostEntry [IP: 0008] ####
    #### System.Net.IPAddress::GetDefaultLocalAddress [IP: 0049] ####
    #### Ws.Services.Transport.WsNetworkServices::GetLocalIPV4Address [IP: 0003] ####
    #### Ws.Services.Binding.UdpTransportBindingElement::.ctor [IP: 0011] ####
    #### Ws.Services.Transport.UDP.WsUdpServiceHost::.ctor [IP: 0037] ####
    #### Ws.Services.Transport.UDP.WsUdpServiceHost::.cctor [IP: 0003] ####
    #### SocketException ErrorCode = -1
    #### SocketException ErrorCode = -1
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll
    #### SocketException ErrorCode = -1
    #### SocketException ErrorCode = -1
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Using mainboard GHI Electronics FEZSpider version 1.0

Loading a full blown DPWS app causes the usual error on Device.Start:

Start DPWS device service with endpoint address: 'urn:uuid:18571766-87df-06e2-bb68-5136c48f483f'
    #### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
    #### Message: 
    #### Microsoft.SPOT.Net.SocketNative::setsockopt [IP: 0000] ####
    #### System.Net.Sockets.Socket::SetSocketOption [IP: 0012] ####
    #### Ws.Services.Binding.UdpTransportBindingElement::OnOpen [IP: 00ae] ####
    #### Ws.Services.Binding.BindingElement::Open [IP: 0015] ####
    #### Ws.Services.Binding.BindingElement::Open [IP: 000f] ####
    #### Ws.Services.Binding.ReplyChannel::Open [IP: 0012] ####
    #### Dpws.Device.Device::Start [IP: 001b] ####
    #### BDGadgetControl.ServiceManager::StartService [IP: 00d7] ####
    #### GadgetController.Program::ethernet_J11D_NetworkUp [IP: 000e] ####
    #### Gadgeteer.Modules.Module+NetworkModule::OnNetworkEvent [IP: 004d] ####
    #### 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: 0020] ####
    #### SocketException ErrorCode = 10049
    #### SocketException ErrorCode = 10049
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll
    #### SocketException ErrorCode = 10049
    #### SocketException ErrorCode = 10049
Error invoking method "Gadgeteer.Modules.Module+NetworkModule" (check arguments to Program.BeginInvoke are correct)


#17

Yep, same here – I am not using the Simple Service, however am using same approach to how SimpleService is built and also used MFSvcUtil.exe to generate the proxies. The exception is thrown on Dpws.Device.Device.Start:

#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message: 
#### Microsoft.SPOT.Net.SocketNative::setsockopt [IP: 0000] ####
#### System.Net.Sockets.Socket::SetSocketOption [IP: 0012] ####
#### Ws.Services.Binding.UdpTransportBindingElement::OnOpen [IP: 00ae] ####
#### Ws.Services.Binding.BindingElement::Open [IP: 0015] ####
#### Ws.Services.Binding.BindingElement::Open [IP: 000f] ####
#### Ws.Services.Binding.ReplyChannel::Open [IP: 0012] ####
#### Dpws.Device.Device::Start [IP: 001b] ####
#### RESTapiConsole.Program::Start [IP: 00a4] ####
#### RESTapiConsole.Program::Main [IP: 004a] ####
#### SocketException ErrorCode = 10049
#### SocketException ErrorCode = 10049

A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10049
An unhandled exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll

I am using the latest SDK updates (February) on a Spider board.


#18

The issue is joining a multicast group, the following line throws the exception when DPWS tries to start the UDP server:

m_udpReceiveClient.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, multicastOpt);

This issue is documented in this thread also: http://www.tinyclr.com/forum/topic?id=10337&page=1


#19

Gus said it was fixed in internal build a month ago (based on the other thread NickP). Does that mean it didn’t make it into the latest 4.2 release? I noticed in the release notes it says UDP fixed, and while I had another UDP issue that seems to be resolved now, the DPWS issue still seems to be there…


#20

UDP is fixed. If you see any issue, please isolate ti outside DPWS to see if ti is UDP related or something else.