Welcome to the new home of the Cumulus Support forum.

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See the Wiki for download

error SocketException Address already in use

Discussion of version 3 of Cumulus, which runs on Windows, Linux, and OS X. All Cumulus MX queries in here, please.
Post Reply
User avatar
novy
Posts: 27
Joined: Thu Feb 16, 2017 2:37 pm
Weather Station: davis vantage vue
Operating System: Windows 7 / RASPBIAN
Location: Scotland

error SocketException Address already in use

Post by novy » Fri Sep 15, 2017 7:44 am

error SocketException: Address already in use Process dead but pidfile exist

Hi

my weather station and cumulus was working fine until i made a back up of my raspberry pi . after rebooting after doing a back up i get this error and am getting no data from the weather station or on localhost page
anyone know how to fix this ?

pic below
https://image.ibb.co/micFtk/Untitled.jpg

Image
Last edited by novy on Fri Sep 15, 2017 10:41 am, edited 1 time in total.

jank
Posts: 304
Joined: Sat Jun 13, 2015 5:57 pm
Weather Station: weatherstation
Operating System: Debian Wheezy
Location: Germany

Re: error SocketException: Address already in use

Post by jank » Fri Sep 15, 2017 9:04 am

novy wrote:error SocketException: Address already in use Process dead but pidfile exist
anyone know how to fix this ?
Hello Novy
On top of the screenshot I can see this text:
/etc/init.d/cumulusmx status
Sep 16 ..... CumulusMX init.d-Script: CumulusMx is being startet at system boot
Process dead but Pidfile exist


And then, you are trying to start CumulusMX manually again.....and it tells you, that it can not bind to the TCP Port, because it is already in use.
Maybe CumulusMX process died, but the TCP Port is still in use
I would suggest the follwoing: start CumulusMX manually, but try another TCP Port for the WebUI:
sudo mono CumulusMX.exe -port 8888
Does it work without an error? If yes, test the WebUI by connecting tp Port 8888 (http://ip_address:8888)

Maybe alternatively you can try to kill CumulusMX completely (or Mono in this case)
the command pidof mono will give you one or more numbers
sudo kill -9 [number]

Now you can try to start CumulusMX manually again.

But it looks like your CumulusMX which is being started by the init.d script is crashing.....so we should remove the init.d Script you are using from /etc/init.d to not automatically start it at system boot. If you are using my init.d script do a:
sudo mv /etc/init.d/cumulusmx /home/pi/cumulusmx to move it from /etc/init.d to /home/pi/
when you reboot now, CumulusMX will not be started at systemboot anymore.
Once you found the error why CumulusMX died at boot, you can move the init.d script back to /etc/init.d

so 3 options for you.......
Want to see your Station values on SSH? Cumulusnow http://sandaysoft.com/forum/viewtopic.php?f=27&t=14062
Want a Start|Stop|Restart Script for CumulusMX on RaspberryPi? cumulusmx.sh http://sandaysoft.com/forum/viewtopic.php?f=27&t=13767

User avatar
novy
Posts: 27
Joined: Thu Feb 16, 2017 2:37 pm
Weather Station: davis vantage vue
Operating System: Windows 7 / RASPBIAN
Location: Scotland

Re: error SocketException: Address already in use

Post by novy » Fri Sep 15, 2017 9:37 am

Hi thanks for the info
i ran sudo mono CumulusMX.exe -port 8888

pi@raspberrypi:~/CumulusMX $ sudo mono CumulusMX.exe -port 8888
Current culture: English (United Kingdom)
Serial: 74FECEABEB2DA94ECB5EBA0CD11A7137
Cumulus MX v.3.0.0 build 3043
Today.ini = data/today.ini
Last update=2017-09-15T10:30:00
Connected to station
10:33:49 Downloading Archive Data
10:33:49 Downloading Archive Data
Cumulus running at: http://*:8888/
(Replace * with any IP address on this machine, or localhost)
Starting web socket server on port 8002
10:33:50 Normal running
15/09/2017 10:33:50
Type Ctrl-C to terminate


data has now downloaded from davis console and localhost page on port 8888 is running .
i tried command pidof mono but nothing came up ?

I have removed the init.d/cumulusmx script and rebooted. cumulus did not start at boot and port 8998 is still in use . i started manually on port 8888 and everything is working fine. its not a problem for me leaving it on port 8888 now but would like to kill port 8998 .

this is what inside the init.d

#!/bin/bash
# /etc/init.d/cumulusmx
### BEGIN INIT INFO
# Provides: cumulusmx.sh
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start cumulusmx.sh (CumulusMX) at boot time
# Description: Enable service provided by daemon.
# chkconfig: 2345 95 05
# Version: 1.2 - 08.06.2016
### END INIT INFO
CumulusMX_HOME=/home/pi/CumulusMX
CumulusMX_USER=root

NAME=CumulusMX
PIDFILE=/tmp/$NAME.pid

# Wait until external drive with CumulusMX is mounted
x=0
while [ "$x" -lt 300 -a ! -e $CumulusMX_HOME/Cumulus.ini ]; do
x=$((x+1))
sleep .1
done
if [ -e $CumulusMX_HOME/Cumulus.ini ]
then
echo "$(date +"%b %d %H:%M:%S") CumulusMX init.d-Script: CumulusMX is being started at system boot within "$x" seconds"
else
echo "$(date +"%b %d %H:%M:%S") CumulusMX init.d-Script: CumulusMX could not be started - unable to mount "$CumulusMX_HOME" within 30 seconds"
exit 1
fi
# End - Wait until external drive with CumulusMX is mounted

case $1 in
start)
printf "%-50s" "Starting $NAME..."
WHOAMI=$(whoami)
if [ "$CumulusMX_USER" != "$WHOAMI" ]; then
/bin/su $CumulusMX_USER $CumulusMX_HOME/cumulusmx.sh >/dev/null 2>&1
else
$CumulusMX_HOME/cumulusmx.sh >/dev/null 2>&1
fi
;;
stop)
echo -e "Stopping $NAME\n"
$CumulusMX_HOME/cumulusmx.sh -q >/dev/null 2>&1
;;
restart)
printf "%-50s" "Restarting $NAME"
$CumulusMX_HOME/cumulusmx.sh -r
;;
force-reload)
printf "%-50s" "Reloading $NAME"
$CumulusMX_HOME/cumulusmx.sh -q
$CumulusMX_HOME/cumulusmx.sh
;;
status)
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
printf "%s\n" "Process dead but pidfile exists"
else
echo "Running"
fi
else
printf "%s\n" "Service not running"
fi
;;
*)
echo "Usage: /etc/init.d/cumulusmx {start|stop|force-reload|status}"
exit 1
;;
esac
exit 0

jank
Posts: 304
Joined: Sat Jun 13, 2015 5:57 pm
Weather Station: weatherstation
Operating System: Debian Wheezy
Location: Germany

Re: error SocketException Address already in use

Post by jank » Fri Sep 15, 2017 11:03 am

Hello Novy
the init.d script you are using is indeed the one I wrow .....and I can also see that you are using the CumulusMX Start Stop script (cumulusmx.sh)
however, you removed the init.d Script which is a kind of autostart job when the system boots up.
You wrote, that you moved (or removed) the /etc/init.d/cumulusmx file out of this folder, but when you check after reboot, Port 8998 is still in use.
This means, something is still starting and using this Port after reboot.

What happens if you point your webbrowser to this port? Which page is being displayed ?
Are you really sure, that you are NOT starting /home/pi/CumulusMX/cumulusmx.sh with a cron job for example ?
PLease use these commands to check
crontab -l
sudo crontab -l

or the output of this command:
sudo ls /etc/cron*
Btw: As far as I can see your problem (but maybe I am wrong) something is still starting CumulusMX (because the default Port 8998 is in use) but it is crashing/dieing for any reason and when you try to start CumulusMX manually, the TCP Port configured is still in use. If you start CumulusMX with another Port, it is workign.
You need to find out, why is CumulusMX still being started a systemboot
Want to see your Station values on SSH? Cumulusnow http://sandaysoft.com/forum/viewtopic.php?f=27&t=14062
Want a Start|Stop|Restart Script for CumulusMX on RaspberryPi? cumulusmx.sh http://sandaysoft.com/forum/viewtopic.php?f=27&t=13767

User avatar
novy
Posts: 27
Joined: Thu Feb 16, 2017 2:37 pm
Weather Station: davis vantage vue
Operating System: Windows 7 / RASPBIAN
Location: Scotland

Re: error SocketException Address already in use

Post by novy » Fri Sep 15, 2017 8:17 pm

Hi jank thanks for your help

yes that is correct the cumulus.sh file is now inside cumulusmx folder and not in the init.d folder

if i start cumulus on port 8998 its already in use
if i start cumulus on 8888 everything works fine
if i then go to port 8998 the web page is still there but no data is being received
if i go to port 8888 at the same time the website is there and working fine

could it be apatche2 is still using this port 8998 ?
i have tried stopping the server then 8998 is gone along with 8888
after reboot 8998 webpage is back but no data is being received
and 8888 is not there untill i manualy start cumulus to run on 8888

results of the cron

pi@raspberrypi:~ $ sudo ls /etc/cron*
/etc/crontab

/etc/cron.d:
php5

/etc/cron.daily:
apache2 aptitude dpkg man-db passwd
apt bsdmainutils logrotate ntp samba

/etc/cron.hourly:
fake-hwclock

/etc/cron.monthly:

/etc/cron.weekly:
man-db

User avatar
novy
Posts: 27
Joined: Thu Feb 16, 2017 2:37 pm
Weather Station: davis vantage vue
Operating System: Windows 7 / RASPBIAN
Location: Scotland

Re: error SocketException Address already in use

Post by novy » Fri Sep 15, 2017 10:45 pm

ok i went into apache2 settings and changed the default listen port to 8888 as it was set to 8998.
stop and restart server
reboot
tried to run cumulusmx on port 8888 and got the same error as before on 8998.
changed default apache2 listen port back to 8998
i ran cumulsmx on port 8888 and all working good .

http://192.168.1.11:8998 webpage loaded but not receiving data
http://192.168.1.11:8888 webpage loaded receiving data


EDIT:

i uninstalled apache2
sudo apt-get --purge remove apache2
sudo apt-get autoremove

rebooted

on restart ive not installed apache2 again but apache2 has restarted and cumulusmx has restarted both now on port 8888 localhost working fine .
port 8998 is now closed no localhost webpage on port 8998 .

am thinking ive had two separate instances of apache running to cause this problem . how would cumulus restart at boot if ive not put the sh script back into init.d ?

jank
Posts: 304
Joined: Sat Jun 13, 2015 5:57 pm
Weather Station: weatherstation
Operating System: Debian Wheezy
Location: Germany

Re: error SocketException Address already in use

Post by jank » Sat Sep 16, 2017 3:04 pm

novy wrote:ok i went into apache2 settings and changed the default listen port to 8888 as it was set to 8998.
stop and restart server
reboot
tried to run cumulusmx on port 8888 and got the same error as before on 8998.
changed default apache2 listen port back to 8998
i ran cumulsmx on port 8888 and all working good .

http://192.168.1.11:8998 webpage loaded but not receiving data
http://192.168.1.11:8888 webpage loaded receiving data
:shock: Not sure who told you to install a seperate webserver (Apache or NgineX) to work with CumulusMx, but Cumulus brings his own small webserver.
Thats your Problem...apache is starting on port 8998 and later the buildin CumulusMX webserver is also trying to start on this port.
You can remove Apache from this Raspberry if you don't want to run a seperate web, or if you want to still use it for anything else, configure Apache to listen on Port 80 and/or 443 and let CumulusMX run on the default port 8998 or whatever port you prefer....but NOT on the same port as any oher application which is running on this device.
Once this is done and proofed by you, please copy the cumulusmx init.d script back top /etc/init.d/cumulusmx
Make a reboot and test if CumulusMX is being started.
Let me know if this workls for you
Jan
Want to see your Station values on SSH? Cumulusnow http://sandaysoft.com/forum/viewtopic.php?f=27&t=14062
Want a Start|Stop|Restart Script for CumulusMX on RaspberryPi? cumulusmx.sh http://sandaysoft.com/forum/viewtopic.php?f=27&t=13767

User avatar
novy
Posts: 27
Joined: Thu Feb 16, 2017 2:37 pm
Weather Station: davis vantage vue
Operating System: Windows 7 / RASPBIAN
Location: Scotland

Re: error SocketException Address already in use

Post by novy » Sat Sep 16, 2017 4:23 pm

Once i had a web page hosted from my pc and i used apache to do this i just thought this would be the same.
So i do not even need apache to host this web page online
I ran remove apache again and its not installed on my pi

pi@raspberrypi:~ $ sudo apt-get --purge remove apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'apache2' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.
pi@raspberrypi:~ $


and everything is still working fine local and web so its running from cumulus own web server now on port 8888

pi@raspberrypi:~ $ /etc/init.d/cumulusmx status
Sep 16 17:17:09 CumulusMX init.d-Script: CumulusMX is being started at system boot within 0 seconds
Checking CumulusMX... Running


Thanks nov.

User avatar
steve
Cumulus Author
Posts: 26713
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: error SocketException Address already in use

Post by steve » Sat Sep 16, 2017 5:49 pm

If you want to use your system as a web server to display pages on the internet, then yes, you need apache or some other web server (the simple web server built in to Cumulus MX is for its own user interface only). But the default port is 80 for a standard web server, not 8998 as used by MX for its own internal display. It would be very unusual to change apache to use port 8998 rather than 80, and will interfere with the normal operation of Cumulus.
Steve

User avatar
novy
Posts: 27
Joined: Thu Feb 16, 2017 2:37 pm
Weather Station: davis vantage vue
Operating System: Windows 7 / RASPBIAN
Location: Scotland

Re: error SocketException Address already in use

Post by novy » Sun Sep 17, 2017 8:31 am

what i have done now i don't no why i never done it this way in the first place

copied the cumulusmx webfiles folder contents to a new folder on my pi
copied the cumulusmx web folder contents to the new folder
set up cumulus ftp upload setting path to the new folder
pointed apache2 to the new folder
set the apache2 listen port to 99 as port 80 will not work for me
open/forward port 99 on my router to my raspberry pi ip address
on 123-regi setup web forwarding to my public ip and port http://11.11.111:99/index.htm

all working now

site is working although not all the data is being displayed on some parts of the dashboard version website. all is ok on the web version
Last edited by novy on Wed Sep 20, 2017 10:26 pm, edited 2 times in total.

jank
Posts: 304
Joined: Sat Jun 13, 2015 5:57 pm
Weather Station: weatherstation
Operating System: Debian Wheezy
Location: Germany

Re: error SocketException Address already in use

Post by jank » Sun Sep 17, 2017 1:38 pm

Now I understand what you are doing and why you have apache installed on Raspberry. In another forum post you asked the quesiton if it is possible to use the Raspberry as the CumulusMX Weather station and also punblishing the Webnpages which are created by CumulusMX for the visitors.
CumulusMX is managing the Weatherstation and also brings its own Webserver to have a "simple" Dashboard for the admin and managing the settings for the Weatherstation. but these "simple" Webinterface should not be published for the internet. So normally others are using the build in FTP function to upload the generated HTML Weather Webpages to their External Webserver hosted somewhere in the internet. Since you are hosting your own Webpage on you local network (or in your case on the same RaspberryPi) you installed apache to display these Webpages which are being FTP'ed from CumulusMX Folder to the Apache Folder.
No Idea why you can not use PORT 80 on the apache to publish you webpages.....(Problem with your router which is not able to NAT to Port 80)?
But now it make sense to me to understand why you have installed Apache Webserver beside CumulusMX Webserver. And oyur only problem was, that both applications are using the same TCP POrt which will not work
Jan
Want to see your Station values on SSH? Cumulusnow http://sandaysoft.com/forum/viewtopic.php?f=27&t=14062
Want a Start|Stop|Restart Script for CumulusMX on RaspberryPi? cumulusmx.sh http://sandaysoft.com/forum/viewtopic.php?f=27&t=13767

User avatar
novy
Posts: 27
Joined: Thu Feb 16, 2017 2:37 pm
Weather Station: davis vantage vue
Operating System: Windows 7 / RASPBIAN
Location: Scotland

Re: error SocketException Address already in use

Post by novy » Sun Sep 17, 2017 5:44 pm

jank wrote:Now I understand what you are doing and why you have apache installed on Raspberry. In another forum post you asked the quesiton if it is possible to use the Raspberry as the CumulusMX Weather station and also punblishing the Webnpages which are created by CumulusMX for the visitors.
CumulusMX is managing the Weatherstation and also brings its own Webserver to have a "simple" Dashboard for the admin and managing the settings for the Weatherstation. but these "simple" Webinterface should not be published for the internet. So normally others are using the build in FTP function to upload the generated HTML Weather Webpages to their External Webserver hosted somewhere in the internet. Since you are hosting your own Webpage on you local network (or in your case on the same RaspberryPi) you installed apache to display these Webpages which are being FTP'ed from CumulusMX Folder to the Apache Folder.
No Idea why you can not use PORT 80 on the apache to publish you webpages.....(Problem with your router which is not able to NAT to Port 80)?
But now it make sense to me to understand why you have installed Apache Webserver beside CumulusMX Webserver. And oyur only problem was, that both applications are using the same TCP POrt which will not work
Jan
Hi jank what i ment to say on the other post was can i use the current cumulusmx dark interface dashboard as my website
sorry i was not more clearer in my question
i now can access the site via internet port 99 on the dark theme dashboard site index.html the gauges do work
but the current temp, pressure, current data, charts, Today and yesterday , Highs and lows and data logs , station/software update clocks do not work.

i get multiple errors in the browser
jquery-latest.min.js:5 GET http://11.111.11.111:99/api/settings/wsport.json 404 (Not Found)
send @ jquery-latest.min.js:5
ajax @ jquery-latest.min.js:5
(anonymous) @ dashboard.js:224
c @ jquery-latest.min.js:3
fireWith @ jquery-latest.min.js:3
ready @ jquery-latest.min.js:3
H @ jquery-latest.min.js:3
18:34:30.011

have tried to open port 8002 just to try but still nothing .

on the other dashboard site index.htm . everything works just fine

User avatar
steve
Cumulus Author
Posts: 26713
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: error SocketException Address already in use

Post by steve » Sun Sep 17, 2017 6:08 pm

You can't use the Cumulus interface files as a standard website using a standard web server such as apache. It isn't a web site, it just looks like one, it only works with Cumulus. It won't work with apache.
Steve

jank
Posts: 304
Joined: Sat Jun 13, 2015 5:57 pm
Weather Station: weatherstation
Operating System: Debian Wheezy
Location: Germany

Re: error SocketException Address already in use

Post by jank » Sun Sep 17, 2017 6:29 pm

Novy.....the way you are using it now is the best way.
As Steve wrote, use the "dark interface" which is only for non public to configure CumulusMX and your weatherstation.
FTP the generated files into another folder and point your Apache to publish them for the inernet users.
Want to see your Station values on SSH? Cumulusnow http://sandaysoft.com/forum/viewtopic.php?f=27&t=14062
Want a Start|Stop|Restart Script for CumulusMX on RaspberryPi? cumulusmx.sh http://sandaysoft.com/forum/viewtopic.php?f=27&t=13767

User avatar
novy
Posts: 27
Joined: Thu Feb 16, 2017 2:37 pm
Weather Station: davis vantage vue
Operating System: Windows 7 / RASPBIAN
Location: Scotland

Re: error SocketException Address already in use

Post by novy » Sun Sep 17, 2017 7:05 pm

thanks guys for your help . but i think i went round in circles doing this lol.
steve you say that It won't work with apache . but i did have all dashboard interface data working on apache2 online when i was running on port 8888 and i opened port 8002 . i suppose i had apache2 on port 8888 and had it directed to the actual interface folder in cumulusmx ? i prefer the look of dashboard thats all
is there not possibly a way for the index page by taking the data from the gauges data to display text data on the index page ?

jank in my router setting for port 80 http 80 is open i think. when i try to manualy open a port 80 connection to my pi ip i get error already open or in use

Management Port Setup
User Define Ports Default Ports
Telnet Port
23
(Default: 23)
HTTP Port
80
(Default: 80)
HTTPS Port
443
(Default: 443)
FTP Port
21
(Default: 21)
TR069 Port
8069
(Default: 8069)
SSH Port
22
(Default: 22)

Post Reply