ESP8266 disconnecting after some weeks - c++

I am trying to keep ESP8266 connected to my WiFi network forever.
Is this possible?
So far it is working only for some weeks and then disconnects from the router. How can I fix it? Maybe a reboot?
Could it be related to Lease Time or another setting in the router?

This can happen due to electronic failure, in other words, there may be overheating, poor contact of the components, a check in the project hardware and eliminate the possibility of a hardware error.

Related

Raspberry Pi watchdogging C++ program

I have C++ app is running on my device which is a bit modified version of Raspberry PI. Application is reading data from a serial port and I need a device to reboot after some particular data is received. I've been wondering about integrating this functionality with watchdog but have no idea how to do it. Maybe there is a possibility to send some signal from my app to watchdog to tell that it's time to reboot?
P.S. Application starts as systemd service.
Call
std::system("sudo reboot");
Why would you do this that way? The reason one uses watchdogs is exactly what Marco described. If a system does not respond the watchdog triggers. Typically this is needed because devices that are lets say turned off do not send anything anymore, therefore you need some kind of trigger to let your system know it should reboot. Here you already get your trigger from the incoming signal therefore the watchdog is redundand. Simply reboot after you have received your data.
Watchdog is great if you want your device to reboot autonomously when your software blocks or Is not reachable anymore
If that is what you want to achieve watchdog is the right choice.

Winsock IOCP Server Stress Test Issue

I have a winsock IOCP server written in c++ using TCP IP connections. I have tested this server locally, using the loopback address with a client simulator. I have been able to get upwards of 60,000 clients no sweat. The issue I am having, is when I run the server at my house and the client simulator at a friends house. Everything works fine up until we hit around 3700 connections, after that every call to connect() fails from the client side with a return of 10060 (this is the winsock timed out error). Last night this number was 3700, but it has been around 300 before, and we also saw it near 1000. But whatever the number is, every time we try to simulate it, it will fail right around that number (within 10 or so).
Both computers are using Windows 7 Ultimate. We have also both modified the TCPIP registry setting MaxTcpConnections to around 16 million. We also changed the MaxUserPort setting from its 5000 default to 65k. No useful information is showing up in the event viewer. We also both watched our resource monitor, and we havent even gotten to 1% network utilization, the CPU is also close to 0% usage as well.
We just got off the phone with our ISP, and they are saying that they are not limiting us in any way but the guy was kinda unsure and ended up hanging up on us anyway after a 30 minute hold time...
We are trying everything to figure this issue out, but cannot come up with the solution. I would be very greatful if someone out there could give us a hand with this issue.
P.S. Both computers are on Verizon FIOS with the same verizon router. Another thing to note, the server is using WSAAccept and NOT AcceptEx. The client simulator is attempting to connect over many seconds though, so I am pretty sure the connects are not getting backlogged. We have tried to change the speed at which the client simulator connects, and no matter what speed it is set to it fails right around the same number each time.
UPDATE
We simulated 2 separate clients (on 2 separate machines) on network A. The server was running on network B. Each client was only able to connect half (about 1600) connections to the server. We were initially using a port below 1,000, this has been changed to above 50,000. The router log on both machines showed nothing. We are both using the Actiontec MI424WR verizon FIOS router. This leads me to believe the problem is not with the client code. The server throws no errors and has no unexpected behavior. Could this be an ISP/Router issue?
UPDATE
The solution has been found. The verizon router we were using (MI424WR revision C) is unable to handle any more than 3700 connections, we tested this with a separate set of networks. Thanks for the help guys!
Thanks
- Rick
I would have guessed that this was a MaxUserPort issue, but you say you've changed that. Did you reboot after changing it?
Run the test on the exact same computers on your local network (this will take the computers out of the equation).
The issue could be one of your routers not being up to the job?

C/C++ detect network type

I need to write a win32 c/c++ application which will be able to determine whether the PC it's running on is connected to one of 2 networks. The first network is the company LAN (which has no internet connection) and the second network is a standalone switch with a single PC connected to it (the PC that the program is running on).
I'm pretty new to network programming but so far I have tried testing to see if a network drive which is held on our LAN can be mapped. This works fine if the PC is connected to the LAN, the drive mapping succeeds so so LAN detection is successful. However, if the PC is connected to the switch, this results in a VERY long timeout which is not a suitable as it will delay the program so much as to make it unusable.
Does anyone have any alternative suggestions?
I'm using c/c++ in VS 6.0
[Update]
Whilst trying a few different ideas and looking at some of the suggestions below I thought I should update with some additional information as many (if not all) of the suggestions I don't think will work.
(1) The aforementioned LAN has no external connections at all, it is completely isolated so no resolving of external DNS or pinging websites is possible.
(2) Hostname, MAC address, IP, Default Gateway, Subnet etc etc (basically everything you see in ipconfig -all) are all manually configured (not dynamic from the router) so checking any of these settings will return the same whether connected to the LAN or the switch.
(3) Due to point (2), any attempts to communicate with the switch seem to be unsuccessful, in fact almost all networking commands (ping, arp etc) seem to fail - I think due to the machine trying to connect to the LAN when it isn't there :-(
One thing I have found which works is pinging the default gateway IP which times out when connected to the switch. This is sort of ok as I can reduce the timeout of ping so it doesn't just hang for ages but it feels like a bit of a hack and I would certainly appreciate any better solutions.
Thanks
As far as TCP/IP is concerned there is no such thing as a LAN on WAN. There are a set of non-internet routable addresses like 192.168.x.x and 10.x.x.x but these are sometimes used by ISP short of IP addresses.
You best bet is to use Asynchronous APIs when making TCP/IP connections. WIN32 defines a whole buch of OVERLAPPED APIs for this purpose. This will prevent your application from grinding to a halt while waiting for a remote connection.
Alternatively put the socket stuff into another thread and then only notify the UI when the operation is done.
I would first try to differentiate between the two using information available locally--that is, from your computer. Does the output of ipconfig /all differ depending on which network you're connected to? If so, exploit that difference if you can.
Is it possible to get the MAC address of the standalone switch? Of the switch that controls the company LAN? That would be a sure way to tell. Unless somebody cloned the MAC address.
If you try using the existence or non-existence of some network service to determine which network you're connected to, you can never be sure. For example, if you failed to map that network drive, all you know is that the network drive isn't available. You can't say for certain that you're not connected to the company LAN. Same is true if you use ping. Lack of response from a particular machine means only that the machine didn't respond.
Various things you can look at for differentiation:
DNS domain name (GetComputerNameEx)
MAC address of gateway (ping it, then GetIpNetTable)
Routing table(do you have a gateway and default route on the company LAN)
WNet discovered network resources (WNetOpenEnum, WNetEnumResource)
Ability to resolve external hostnames (try a 5-10 names like www.google.com, www.microsoft.com and so on, if one resolves you should have internet)
You'll have to decide how many indicators are "enough" to decide you're on one or the other LAN though if tests fail. Then keep retrying until you have a definite result.
http://msdn.microsoft.com/en-us/library/aa366071%28v=VS.85%29.aspx has a lot of network related functions that you can experiment with to create further indicators.

Getting notifications regarding internet connection is gone in linux?

In linux , is it possible to get notification when network connection is down ?
Is the any OS service for which I have to register for such notifications ?
OR is there any DBus Service of it ?
If you're using NetworkManager, it's possible to get status from it (which is, if I remember correctly, done over dbus).
But beware that a lot of Linux machines don't use NetworkManager, so you'll have to handle that. And some machines have more than one network connection, etc.
Further "network connection is down" may not be the most useful thing for you. E.g., it's possible to have a network connection, but the router has lost its Internet connection, so you've only got connectivity to local machines. Or sometimes you'll see partial Internet reachability. Depending on what you need this for, you may need to take other approaches.
Lastly, sometimes network connections die and come back quickly, especially with wireless. These transient changes are probably best ignored (unless the IP address changes).
See this forum thread (linuxquestions.org). Basically you'd need to modify the kernel for pushed notifications. Networkmanager indeed has a DBUS API, but polling periodically is a more general solution.

UDP socket starting to fail to receive

I have a very annoying bug showing up.
We have left our iPhone app running overnight.
Every 2 seconds it sends a broadcast ping out on to the network via the open socket to inform that the device is alive. Now the other application detects that ping and attempts to send messages back. The problem is that despite the ping continuing to go out no packets ever get received.
This only seems to happen after several hours (annoyingly we've only ever managed to get this overnight). It then seems to leave the iphone in a very confused state where even after restarting the app it is still unable to receive the packets. Eventually after a time (sorry I have no idea how long) the phone starts re-acting normally and I can continue.
I'm guessing that somewhere along the line iOS is blocking the socket from receiving data (but oddly not sending on the same socket!).
Has anyone any idea what this might be and, more importantly, how I might solve the issue?
Well this turned out to be a very strange problem.
I broke out a packet sniffer to inspect what was going on and I found that my PC was sending out ARP broadcasts trying to identify who had the ip address. These ARP requests were not getting answered by the router or the iPhone.
This was very strange.
In the end I started checking the wifi access point I was attached to. I disabled the wifi on it forcing us to use a different (though slightly weaker) access point and suddenly the ARP requests were getting answered and everything jumped into life.
It was at this point that I remembered that my Boss had tripped over the wire of the access point and it had come crashing to the ground. It "seemed" to work .. but, evidently, he broke "something" :(
The problem is now no more!