Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

bmcapture process stops monitoring sometimes #30

Open
codebox opened this Issue Mar 18, 2012 · 4 comments

Comments

Projects
None yet
2 participants
Owner

codebox commented Mar 18, 2012

bmcapture process stops monitoring sometimes (on OSX, and possibly others, all pcap thread stop, leaving only main thread running)

Owner

codebox commented Apr 15, 2012

Similar issues reported on Windows 7 after waking from hibernation. Errors in log file on windows relating to bpf compilation problems (see http://codebox.org.uk/forum/posts/list/0/28934.page#40454) which do not appear on OSX, so this may be 2 separate problems

maphew commented Oct 16, 2015

I see this on Win7 and Win10, with Bitmeter 0.8.0. It happens after shutdown as well as hibernate.

The forum link above shows a blank page for me.

Restarting the service restarts data capture. I tried setting up a scheduled task to restart the process on Workstation Unlock event but it had no effect. I couldn't find a reason (hard to troubleshoot scheduled tasks; you have to add your own error logging etc.), but suspect it's around elevated permissions.

I also tried putting the restart batch file in the Startup group (and learned this pro tip: Winkey-R >> shell:startup to get there quickly) but it didn't work there either.

Workaround

Create a shortcut to this batch file and under Advanced properties check "Run as administrator", and run on-demand as needed.

@:: restart-bitmeter-capture-service.bat, save in BitMeter OS install folder
@pushd %~dp0
sc stop  BitMeterCaptureService
sc start BitMeterCaptureService
@ping -n 7 localhost > nul
@   :: pause for 7 secs
@popd

Yesterday I found a post somewhere on Stack Overflow or Server Fault about a possible race condition with services using winpcap. I can't find it again (on a different computer and no access to browser history), but the gist of it was that you needed to start winpcap after the dependent service. I remember it because that order seemed odd to me, because it's the reverse of how I normally think of dependencies.

maphew commented Oct 16, 2015

Finally found the log file (should have read the FAQ first, sorry), it doesn't say much:

2015-10-15 13:14:23 WEB recv() returned 0

2015-10-15 13:14:24 WEB recv() returned 0

2015-10-15 21:13:00 WEB recv() returned 0

The same faq shows bmdb capstop and bmdb capstart for the capture service. Do those do something different from the restart service method I concocted above? (e.g. does it matter which method is used?). The console feedback indicates it might just be a convenience wrapper around sc.

maphew commented Oct 27, 2015

I have a working scheduled task! Fix was to use the Powershell Restart-Service cmdlet instead of my batch file. For debugging the scheduled task you might want/need to enable task history logging. I have it set to trigger on Startup (30s delay), Logon, and Workstation Unlock, and runs under SYSTEM account with highest privileges. Only condition is "run only if any network connection"

The command is simply PowerShell Restart-Service BitmeterCaptureService. There is no console feedback, use Get-Service to query.

To test:

  • disable scheduled task
  • open a browser to the Bitmeter Monitor page
  • put computer to sleep, then re-awake
  • check Monitor. If your computer has the bug, the Current in/out will be zero.
  • enable task
  • repeat sleep>>wake>>monitor. Current in/out should show traffic (might need to wait a few seconds for the task to fire)

The task definition for easy importing: https://gist.github.com/maphew/3c58576f50ebd7513fa6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment