Netduino home hardware projects downloads community

Jump to content


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.
Photo

Application freezing on Socket creation


  • Please log in to reply
10 replies to this topic

#1 Chris Harrod

Chris Harrod

    Member

  • Members
  • PipPip
  • 15 posts

Posted 13 October 2012 - 01:15 PM

Good morning,

I'm trying to troubleshoot a problem where my application fails to run from time to time. It doesn't appear to do it every time, which is pretty irritating.

public PhalanxSocket()
        {
            Debug.Print("Creating socket.");
            this.LineEnding = "";
            this._Sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            Debug.Print("Created socket");
        }

At least half of the time I deploy the application it hangs up creating the socket. Any ideas? I'm running .NET MF 4.1

The workaround is to launch the program with the ethernet cable unplugged and then plug it in after the application is running.

#2 Chris Harrod

Chris Harrod

    Member

  • Members
  • PipPip
  • 15 posts

Posted 13 October 2012 - 01:21 PM

I'm wondering if this has anything to do with my problem.

Work Item 1338

#3 Chris Harrod

Chris Harrod

    Member

  • Members
  • PipPip
  • 15 posts

Posted 13 October 2012 - 01:37 PM

Actually, this is the exact problem I'm having.

NeonMika Socket fail

And one more person.

http://forums.netdui...s-program-hang/

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 13 October 2012 - 03:28 PM

This does sound like the bug addressed in .NET MF 4.3. We should have a beta release of .NET MF 4.3 within the next few weeks. The lwIP stack has been upgraded from 1.3.2 to 1.4.0, so it includes more than a year of lwIP bug fixes as well. Chris

#5 Chris Harrod

Chris Harrod

    Member

  • Members
  • PipPip
  • 15 posts

Posted 13 October 2012 - 07:16 PM

Good to hear, Chris. Until then, if anyone experiences this problem while deploying applications you can unplug the Ethernet cable and deploy your application.

#6 Ellen

Ellen

    Advanced Member

  • Members
  • PipPipPip
  • 65 posts
  • LocationRotterdam, Netherlands

Posted 15 October 2012 - 02:02 PM

Good to hear, Chris. Until then, if anyone experiences this problem while deploying applications you can unplug the Ethernet cable and deploy your application.

Chris,
serious, try the next:
- deploy your N+ with a static IP address
- Go to your router, forward your port with a new port like 54321 (example)
- in your code, in stead of port 80, the new port.
bye-bye trouble......

snippet example....
const iPORT as integer = 54321 (example)
Dim hostEntry As IPHostEntry = Dns.GetHostEntry(host)
Dim hostAddress As IPAddress = hostEntry.AddressList(0)
Dim remoteEndPoint As New IPEndPoint(hostAddress, iPORT)
Dim connection = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
connection.Connect(remoteEndPoint)
          


#7 GregR

GregR

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts
  • LocationKeller, Tx

Posted 15 October 2012 - 02:54 PM

Chris,
serious, try the next:
- deploy your N+ with a static IP address
- Go to your router, forward your port with a new port like 54321 (example)
- in your code, in stead of port 80, the new port.
bye-bye trouble......

snippet example....

const iPORT as integer = 54321 (example)
Dim hostEntry As IPHostEntry = Dns.GetHostEntry(host)
Dim hostAddress As IPAddress = hostEntry.AddressList(0)
Dim remoteEndPoint As New IPEndPoint(hostAddress, iPORT)
Dim connection = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
connection.Connect(remoteEndPoint)
          



I also see that this example is using a TCP connection where the original code at the top of the thread was using UDP. So more than one thing changed. The protocol changed AND the port number changed.

#8 Nicky

Nicky

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationDenmark

Posted 15 October 2012 - 03:14 PM

It's a longshot, but if youre using dhcp on your Netduino, try to add this before running the reset of your program:

while(Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress == "0.0.0.0");

ntools
TCP Listener (Beta) · FTP Server (Alpha)
Netduino Plus Go Module · Xml Parser
http://ntools.codeplex.com/


#9 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

Posted 15 October 2012 - 08:42 PM

Nicky, Good Catch! I had to do something similar with my web server. All TCP/IP communications would hang until the Netduino would get an IP Address when the Netduino was configured for DHCP. Another thing to watch out for, is your app will hang if the Netduino is configured for DHCP and you are not connected to a network. I ran into that a couple of times as well.
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com

#10 Chris Harrod

Chris Harrod

    Member

  • Members
  • PipPip
  • 15 posts

Posted 22 October 2012 - 10:41 PM

Mine is static IP. =\ It's set using MFDeploy, not code. Not sure if that would matter. Also, this would happen even if I didn't have a router in the loop. Just a straight cable to my deploying PC. There are a few routers on the same subnet, though.

#11 Fjolle

Fjolle

    New Member

  • Members
  • Pip
  • 7 posts

Posted 14 December 2012 - 02:13 PM

Hi. I seem to have the same problem. The netduino sometimes completely freezes when trying to create a socket. Pressing reset doesn't do anything. The only way for it to recover is to cut the power completely. Is there a way to avoid this, or any date when the 4.3 (which hopefully would fix this) is released?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.