Webserver

Questions and comments specific to a particular plugin should go here.
User avatar
topix
Experienced User
Posts: 380
Joined: Sat May 05, 2007 3:43 pm
Location: Germany
Contact:

Re: Webserver

Post by topix » Sat Aug 05, 2017 11:36 am

I tried to replicate the freeze but wasn't able. I tried webserver 3.13.4 with EG 05-RC4 and EG 0.4.1r1722.

If you haven't done yet, please try with new clean config. Add only webserver plugin and empty folder as webroot. (That's how i tested)
I'm also willing to try someone else configtree. Maybe i'm then able to reproduce the freeze.

wysocki
Posts: 43
Joined: Mon Nov 23, 2015 9:23 pm
Location: Los Angeles area

Re: Webserver

Post by wysocki » Mon Aug 07, 2017 9:29 pm

PROGRESS AT LAST!
Thanks, topix, for getting me fired up on figuring this out. The past couple of days I've been going through all sorts of permutations to isolate the issue. Turns out, it's not in the config nor the version of EG or webserver. The problem only appears for me if I have Muscbee invoked in my webserver page!

My index.html has an iframe which includes code to display Musicbee controls (see below). If I take that out of the page, webserver loads the page properly after an EG restart and I don't have to reboot the server. Now for someone to fix this!
Thanks again!

Code: Select all

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<title>MusicBee remote</title>
<link rel="shortcut icon" href="apple-touch-icon-57x57-precomposed.png" />
<link rel="apple-touch-icon" sizes="114×114" href="apple-touch-icon-114x114-precomposed.png" />
<link rel="apple-touch-icon" sizes="72×72" href="apple-touch-icon-72x72-precomposed.png" />
<link rel="apple-touch-icon" href="apple-touch-icon-57x57-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="114×114" href="apple-touch-icon-114x114-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="72×72" href="apple-touch-icon-72x72-precomposed.png" />
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-57x57-precomposed.png" />
<link rel="stylesheet" href="./css/style.css" />
<script src="js/jquery-2.0.3.min.js"  type="text/javascript"></script>
<script src="js/script.js"></script>
<script src="js/jquery.alerts.js" type="text/javascript"></script>
<link href="css/jquery.alerts.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<table  style="position: absolute; top: 3px; left:4px; width: 128px; height: 128px;">
  <tr>
    <td style = "cursor:pointer;" id = "thumbnail" data-action="MB.play/pause"><img style="width: 128px; height: 128px; float:left" id = "playbutton" alt=""></td>
  </tr>
</table>
<div class = "nowrap trackFields"     style="font-weight:bold;font-size:20px">
  <div id="trackTitle">&nbsp; </div>
  <div class = "field" id="artist">&nbsp; </div>
  <div class = "field" id="album">&nbsp; </div>
  <div class = "field" id="year">&nbsp; </div>
</div>
<div style="width: 112px; height: 24px; position: absolute; left: 136px; top: 108px; " > <img style="width: 112px; height: 24px; float:left" id = "rating" alt=""> </div>
<div class = "controls" style="position: absolute; top: 137px;">
  <div>
<div style="float:left">
    <button  data-action="MB.prev"> <img src = "./images/buttons/backward.png" class = "imgButton" alt=""> </button>
    <button  data-action="MB.stop"> <img src = "./images/buttons/stop.png"  class = "imgButton" alt=""> </button>
    <button  data-action="MB.next"> <img src = "./images/buttons/forward.png"  class = "imgButton" alt=""> </button>
</div>
<div class = "field" id="info" style="float:left">&nbsp; </div>
    <br/>
    <div class="smartSliderB">&nbsp;</div>
    <div class="select-styled">
      <select id="playlists">
      </select>
    </div>
    <div class="select-styled">
      <select id="tracks">
      </select>
    </div>
  </div>
</div>
</body>
</html>

User avatar
topix
Experienced User
Posts: 380
Joined: Sat May 05, 2007 3:43 pm
Location: Germany
Contact:

Re: Webserver

Post by topix » Sun Aug 13, 2017 6:46 am

@wysocki: ggod to hear that you found the problematic code. If you can give me the config details and the files to replicate the website, i would test it on my system.

MaxMan23
Posts: 18
Joined: Sat Jun 29, 2013 4:36 am

Re: Webserver

Post by MaxMan23 » Sun Aug 20, 2017 6:01 pm

Hi, i have a problem with the Webserver. I got rigger loops.

I send a script one times from my homematic:
string url="http://192.168.xxx.xx:xxxx/?KodiPause";
dom.GetObject("CUxD.CUX2801001:1.CMD_EXEC").State("wget -q -O - "#url);


And after i send it i got a trigger loop, every xx seconds, until i deaktivate the Webserver.


19:53:02 HTTP.Started 'Webserver started as unsecured (http://) on port xxxx'
19:53:19 Task.Activated.firefox
19:53:27 HTTP.KodiPause []
19:53:27 MediaPortal: Pause
19:53:27 Python Skript
19:53:28 HTTP.KodiPause []
19:53:28 MediaPortal: Pause
19:53:28 Python Skript
19:53:29 Task.Deactivated.firefox
19:53:29 Task.Activated.EventGhost
19:53:30 HTTP.KodiPause []
19:53:30 MediaPortal: Pause
19:53:30 Python Skript
19:53:33 HTTP.KodiPause []
19:53:33 MediaPortal: Pause
19:53:33 Python Skript
19:53:37 HTTP.Stopped 'Webserver on port xxxx stopped'




Can someone help me with this problem, please.

User avatar
kgschlosser
Site Admin
Posts: 3030
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Webserver

Post by kgschlosser » Mon Aug 21, 2017 3:11 am

well the only thing i can think of that would cause this behavior is homematic keeps on repeating the pause command. the webserver shouldn't behave like this all on it's own. and the fact that you keep on getting the events leads me to believe that they keep on being sent over. you can test this simply by manually sending the command yourself. open your browser on the PC that is running EG and the webserver plugin and key the following into the address bar and press enter. see if you only get an event one time in EG. if you do and it does not repeat that it means the issue is with homematic

Code: Select all

localhost/?KodiPause
If you like the work I have been doing then feel free to Image

scottsams
Experienced User
Posts: 55
Joined: Fri Jul 07, 2017 9:59 pm

Re: Webserver

Post by scottsams » Thu Aug 24, 2017 12:22 am

I am having issues with my webserver plugin and cannot figure out what is going on. this usually occurs after a reboot - which i have to do often. usually a second reboot fixes the issue. i am on windows 10. i have reinstalled plugin, reinstalled EG as well to no avail. can you help? any info you need, let me know. it happens on all my webserver events.

HTTP.ST.Kitchen Motion Sensor.motion.active []
Send Event ST.Kitchen Motion Sensor.motion.active
Webserver: Send event to another EventGhost: ST.Kitchen Motion Sensor.motion.active
Error in Action: "Webserver: Send event to another EventGhost: ST.Kitchen Motion Sensor.motion.active"
Traceback (most recent call last) (0.5.0-rc4):
File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 116, in CallWrapper
return self(*args)
File "C:\Program Files (x86)\EventGhost\plugins\Webserver\__init__.py", line 4141, in __call__
Request("TriggerEnduringEvent", event)
File "C:\Program Files (x86)\EventGhost\plugins\Webserver\__init__.py", line 4127, in Request
sock.send("\r\n".join(data))
AttributeError: 'NoneType' object has no attribute 'send'

m19brandon
Experienced User
Posts: 177
Joined: Mon Feb 03, 2014 10:36 pm

Re: Webserver

Post by m19brandon » Fri Aug 25, 2017 1:04 am

Did you get this working?

I would add the ping plugin if not, figured it when it stops responding and then run a batch command "tracert ip > some file". That will tell you where in the network the issue is.

User avatar
topix
Experienced User
Posts: 380
Joined: Sat May 05, 2007 3:43 pm
Location: Germany
Contact:

Re: Webserver

Post by topix » Fri Aug 25, 2017 6:08 pm

I've added an exception check to the Request function. If the send fails it will (hopefully) print an error message.
Attachments
Webserver_3_13_5.egplugin
Plugin: Webserver 3.13.5
(68.3 KiB) Downloaded 47 times

scottsams
Experienced User
Posts: 55
Joined: Fri Jul 07, 2017 9:59 pm

Re: Webserver

Post by scottsams » Fri Aug 25, 2017 6:56 pm

yea turns out an IP changed on network and so it was unreachable. thanks

wysocki
Posts: 43
Joined: Mon Nov 23, 2015 9:23 pm
Location: Los Angeles area

Re: Webserver

Post by wysocki » Thu Aug 31, 2017 11:04 pm

@topix:
Sorry about not responding on the "restart-eg-kills-webserver" issue, but I was trying to isolate the exact piece of code in my web page that caused it. I've failed because for some weird reason, everything started working fine again! I restored my old website completely and ran (and re-ran) 0.5.0-rc4 with no problems at all!

Well, that was a couple weeks ago. Today I restarted EG and voila, my webserver was dead! Same old story, I had to restart the server machine to get the webserver running again. I'll be playing with the code again to see if I can pin it down if possible. If I log debug info, would that provide any guidance as to why the webserver won't restart properly with EG? I will pm you a zip of my files.

User avatar
topix
Experienced User
Posts: 380
Joined: Sat May 05, 2007 3:43 pm
Location: Germany
Contact:

Re: Webserver

Post by topix » Sat Sep 02, 2017 8:36 am

@wysocki: A debug log could help. Also try the version of the plugin in my previous post, it could also give a little more info on failing commands.

User avatar
kgschlosser
Site Admin
Posts: 3030
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Webserver

Post by kgschlosser » Sun Sep 03, 2017 10:29 pm

@ topix

You are more familiar with this plugin then I. I am assuming sockets is being used.

is there anything like this for the initial creation of the socket?

Code: Select all

self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

@wysocki
I am going to poke at the code a bit and see if i can't isolate why the port is not being closed.

If you can do me a favor next time it hangs..

do this 2 times. once when EG is hung. and then i want you to kill the eventghost process in task manager and then run it again after you killed it

paste this into an elevated command prompt and it is going to spit out some information into a file on your desktop called netstat_results.txt

You are going to need to change one thing in the code below. you need to change *****WEBSERVER_PORT***** to the port you have the webserver plugin set to.

Code: Select all

PowerShell -ExecutionPolicy ByPass -Command "$netstat = NetStat -abfnot | select-string ':*****WEBSERVER_PORT*****';$netstat;foreach($n in $netstat) {$segs = $n -split('       ');Get-Process -Id $segs[-1] | Select-Object | Format-List *;'-------------------------------------'};" >> %userprofile%\desktop\netstat_results.txt
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 3030
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Webserver

Post by kgschlosser » Sun Sep 03, 2017 10:38 pm

I wanted to tell you what that command is going to do.

It is going to leverage the use of netstat through powershell netstat is able to list all open ports for us and what process id opened that port. with powershell we are able to parse the output from that and only select the port relevant to EG and the webserver plugin. and from that output we grab the process ID if there are any results for the port still being in use. and then we spit out a whole mess of stuff about the process that has captured the port might tell us as to why it is getting stuck open like that. because usually when you kill a process it tanks the port with it. so i am wondering why it is getting orphaned and left open. this might give us some insight as to what is holding it open. it could very possibly be some other program is trying to latch on to the same port for some reason and this causes EG to hang and when you kill EG that other program has control of the port. so when you try to open EG and the webserver plugin it might not be able to grab the port because it is in use. and a reboot would close that other program hence why EG can grab it once again after the reboot. and this seems like an "intermittent" issue because of when that other program runs. or possibly performs a specific task at some very unspecific time.

but this will let us know what is going on hopefully
If you like the work I have been doing then feel free to Image

User avatar
topix
Experienced User
Posts: 380
Joined: Sat May 05, 2007 3:43 pm
Location: Germany
Contact:

Re: Webserver

Post by topix » Mon Sep 04, 2017 5:42 pm

kgschlosser wrote:@ topix

You are more familiar with this plugin then I. I am assuming sockets is being used.

is there anything like this for the initial creation of the socket?

Code: Select all

self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
No, no, not familar, only did some debugging. the plugin uses WebSocket(App) which uses socket. In the webserver plugin i see uses of AF_INET6 and SOCK_STREAM.

User avatar
kgschlosser
Site Admin
Posts: 3030
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Webserver

Post by kgschlosser » Mon Sep 04, 2017 9:38 pm

@topix

I am more curious about the second line as this is the one that allows the reuse of a port. Now that being said if the port it open and orphaned then it will not work. that is the reason i posted that power shell snippit. to see if we can make sure it is stuck and if it is. is it EG that has made it that way.
If you like the work I have been doing then feel free to Image

Post Reply