Webserver

Questions and comments specific to a particular plugin should go here.
User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Webserver

Post by yokel22 » Fri Jan 18, 2019 3:51 pm

I'm not in front of a pc right now. You just need to use the PC's internal ip that runs EG & the port set in the webserver config.

Example: "http://192.168.1.101:80?eventName&payloadValue"

The value before the ampersand is the event & the value after will be the events payload value. You can add multiple payloads if neeeded.

You can do this via python script from EG or HA. Do a search here for "get request" or "http request". It should get you some python examples to look over.
Last edited by yokel22 on Fri Jan 18, 2019 10:54 pm, edited 2 times in total.

phairplay
Posts: 12
Joined: Wed Jan 18, 2017 12:02 pm

Re: Webserver

Post by phairplay » Fri Jan 18, 2019 6:54 pm

yokel22 wrote:
Fri Jan 18, 2019 3:51 pm
I'm not in front of a pc right now. You just need to use the PC's internal ip that runs EG & the port set in the webserver config.

Example: "http:192.168.1.101:80?eventName&payloadValue"

The value before the ampersand is the event & the value after will be yhe events payload value. You can add multiple payloads if neeeded.

You can do this via python script from EG or HA. Do a search here for "get request" or "http request". It should get you some python examples to look over.
Thank you this did help I removed my ssl cert which I think linked it to my domain and I was able to use my internal IP address

:D

wysocki
Experienced User
Posts: 56
Joined: Mon Nov 23, 2015 9:23 pm
Location: Los Angeles area

Re: Webserver

Post by wysocki » Wed Mar 06, 2019 12:32 am

Getting errors when I browse to the webserver. Not sure exactly if my html code is causing this or what. Just by doing a RELOAD of the html, I get a string of errors. Here's a log file of when I just hit reload a few times. Oddly, each time caused a shorter error list and after about 5 times, there were no more errors! However, the next time I reboot, the issue comes up again. It may be a result of bad coding in my HTML since I barely understand some of the stuff I coded! EG ver 0.5.0-rc6.

Here's the log file:

Code: Select all

2019-03-05 16:01:11  ERROR: Webserver error /mailbox_flashing.gif
2019-03-05 16:01:11  ERROR: Exception [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:11  ERROR: Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:11  INFO: ----------------------------------------
2019-03-05 16:01:11  INFO: Exception happened during processing of request from ('::ffff:192.168.1.101', 61892, 0, 0)
2019-03-05 16:01:11  ERROR: Traceback (most recent call last):
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-05 16:01:11  ERROR: File "socket.pyc", line 283, in close
2019-03-05 16:01:11  ERROR: File "socket.pyc", line 307, in flush
2019-03-05 16:01:11  ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:11  INFO: ----------------------------------------
2019-03-05 16:01:11  ERROR: Webserver error /musicbee/css/style.css
2019-03-05 16:01:11  ERROR: Exception [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:11  ERROR: Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:11  ERROR: Webserver error /musicbee/css/jquery.alerts.css
2019-03-05 16:01:11  INFO: ----------------------------------------
2019-03-05 16:01:11  ERROR: Exception happened during processing of request from ('::ffff:192.168.1.101', 61894, 0, 0)Exception [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:11  INFO: 
2019-03-05 16:01:11  ERROR: Traceback (most recent call last):
2019-03-05 16:01:11  ERROR: Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-05 16:01:11  INFO: ----------------------------------------
2019-03-05 16:01:11  INFO: Exception happened during processing of request from ('::ffff:192.168.1.101', 61895, 0, 0)
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-05 16:01:11  ERROR: Traceback (most recent call last):
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-05 16:01:11  ERROR: File "socket.pyc", line 283, in close
2019-03-05 16:01:11  ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-05 16:01:11  ERROR: File "socket.pyc", line 283, in close
2019-03-05 16:01:11  ERROR: File "socket.pyc", line 307, in flush
2019-03-05 16:01:11  ERROR: File "socket.pyc", line 307, in flush
2019-03-05 16:01:11  ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:11  ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:11  INFO: ----------------------------------------
2019-03-05 16:01:11  INFO: ----------------------------------------
2019-03-05 16:01:12  EVENT: HTTP.WsClientConnected [('192.168.1.101', 61898)]
2019-03-05 16:01:12  EVENT: HTTP.WsClientConnected [('192.168.1.101', 61899)]
2019-03-05 16:01:12  EVENT: MB.Run
2019-03-05 16:01:12     MACRO: MusicBee: Run MusicBee
2019-03-05 16:01:12        ACTION: MusicBee: Get "Is running": Stop macro if Never
2019-03-05 16:01:12        ACTION: If successful, jump to "Webserver: variables initialization"
2019-03-05 16:01:12           MACRO: Webserver: variables initialization
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Get "Is running": Stop macro if MusicBee is not running
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: Change Master Volume: 0.00 %
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Now playing command: Get artwork thumbnail: 128
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Player command: Get volume
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Player command: Get mute
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Now playing command: Get file tag: Album
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Now playing command: Get file tag: Artist
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Now playing command: Get file tag: TrackTitle
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Player command: Get play state
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Now playing command: Get file tag: Rating
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Now playing command: Get file tag: Lyricist
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Now playing command: Get track info
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Player command: Get shuffle
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Player command: Get repeat mode
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: MusicBee: Player command: Get "Stop after current enabled"
2019-03-05 16:01:12              ACTION: Get Mute Status
2019-03-05 16:01:12              ACTION: Webserver: Set temporary value
2019-03-05 16:01:12              ACTION: Webserver: Broadcast all values
2019-03-05 16:01:12              ACTION: Jump to "Webserver: Broadcast data: Playlist and Tracks"
2019-03-05 16:01:12                 MACRO: Webserver: Broadcast data: Playlist and Tracks
2019-03-05 16:01:12                    ACTION: MusicBee: Playlist command: Get playlists
2019-03-05 16:01:12                    ACTION: Webserver: Broadcast data: Playlists
2019-03-05 16:01:12                       ERROR: Webserver error /musicbee/images/noCover.png
2019-03-05 16:01:12                       ERROR: Exception [Errno 10054] An existing connection was forcibly closed by the remote host
2019-03-05 16:01:12                       ERROR: Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:12                       INFO: ----------------------------------------
2019-03-05 16:01:12                       INFO: Exception happened during processing of request from ('::ffff:192.168.1.101', 61900, 0, 0)
2019-03-05 16:01:12                       ERROR: Traceback (most recent call last):
2019-03-05 16:01:12                       ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-05 16:01:12                       ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-05 16:01:12                       ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-05 16:01:12                       ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-05 16:01:12                       ERROR: File "socket.pyc", line 283, in close
2019-03-05 16:01:12                       ERROR: File "socket.pyc", line 307, in flush
2019-03-05 16:01:12                       ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:12                       INFO: ----------------------------------------
2019-03-05 16:01:12                    ACTION: MusicBee: Playlist command: Get static playlists
2019-03-05 16:01:12                    ACTION: Webserver: Broadcast data: StaticPlaylists
2019-03-05 16:01:12                    ACTION: MusicBee: Now playing list command: Get tracks
2019-03-05 16:01:12                    ACTION: Webserver: Broadcast data: Tracks
2019-03-05 16:01:12  EVENT: MB.RegPosListener [('192.168.1.101', 61898)]
2019-03-05 16:01:12     MACRO: Webserver: Periodically broadcast data: Slider
2019-03-05 16:01:12        ACTION: Webserver: Stop all periodic tasks (broadcast type):
2019-03-05 16:01:12        ACTION: MusicBee: Get "Is running": Stop macro if MusicBee is not running
2019-03-05 16:01:15  EVENT: HTTP.mailbox ['_id1551830473042']
2019-03-05 16:01:15     MACRO: Mailbox RESET
2019-03-05 16:01:15        ACTION: Timer: mailNotify STOP
2019-03-05 16:01:15        ACTION: Webserver: Stop all periodic tasks (broadcast type):
2019-03-05 16:01:15        ACTION: Webserver: Set temporary value
2019-03-05 16:01:15        ACTION: Webserver: Set temporary value
2019-03-05 16:01:15        ACTION: Webserver: Broadcast values
2019-03-05 16:01:15  ERROR: Webserver error /mailbox_monitoring.gif
2019-03-05 16:01:15  ERROR: Exception [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:15  ERROR: Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:15  INFO: ----------------------------------------
2019-03-05 16:01:15  INFO: Exception happened during processing of request from ('::ffff:192.168.1.101', 61903, 0, 0)
2019-03-05 16:01:15  ERROR: Traceback (most recent call last):
2019-03-05 16:01:15  ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-05 16:01:15  ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-05 16:01:15  ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-05 16:01:15  ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-05 16:01:15  ERROR: File "socket.pyc", line 283, in close
2019-03-05 16:01:15  ERROR: File "socket.pyc", line 307, in flush
2019-03-05 16:01:15  ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:01:15  INFO: ----------------------------------------
2019-03-05 16:01:31  EVENT: System.UnIdle
2019-03-05 16:02:37  EVENT: CM11A.ACK
2019-03-05 16:02:37  EVENT: CM11A.D1.On
2019-03-05 16:02:41  EVENT: CM11A.ACK
2019-03-05 16:02:42  EVENT: CM11A.D1.Off
2019-03-05 16:03:02  EVENT: System.Idle
2019-03-05 16:03:02  EVENT: CM11A.ACK
2019-03-05 16:03:03  EVENT: CM11A.D1.On
2019-03-05 16:03:07  EVENT: CM11A.ACK
2019-03-05 16:03:07  EVENT: CM11A.D1.Off
2019-03-05 16:04:08  EVENT: System.UnIdle
2019-03-05 16:05:45  EVENT: System.Idle
2019-03-05 16:06:24  EVENT: System.UnIdle
2019-03-05 16:08:28  EVENT: System.Idle
2019-03-05 16:09:01  EVENT: System.UnIdle
2019-03-05 16:10:07  EVENT: System.Idle
2019-03-05 16:16:23  EVENT: System.ClipboardChanged
2019-03-05 16:16:23  EVENT: System.UnIdle
2019-03-05 16:16:34  NOTICE: Websocket closing: GOING_AWAY
2019-03-05 16:16:34  NOTICE: Websocket closing: GOING_AWAY
2019-03-05 16:16:34  EVENT: HTTP.WsClientDisconnected [('192.168.1.101', 61899)]
2019-03-05 16:16:34  EVENT: HTTP.WsClientDisconnected [('192.168.1.101', 61898)]
2019-03-05 16:16:35  ERROR: Webserver error /musicbee/css/style.css
2019-03-05 16:16:35  ERROR: Exception [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:16:35  ERROR: Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:16:35  INFO: ----------------------------------------
2019-03-05 16:16:35  INFO: Exception happened during processing of request from ('::ffff:192.168.1.101', 62396, 0, 0)
2019-03-05 16:16:35  ERROR: Webserver error /musicbee/css/jquery.alerts.css
2019-03-05 16:16:35  ERROR: Traceback (most recent call last):
2019-03-05 16:16:35  ERROR: Exception [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:16:35  ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-05 16:16:35  ERROR: Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:16:35  ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-05 16:16:35  INFO: ----------------------------------------
2019-03-05 16:16:35  INFO: Exception happened during processing of request from ('::ffff:192.168.1.101', 62397, 0, 0)
2019-03-05 16:16:35  ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-05 16:16:35  ERROR: Traceback (most recent call last):
2019-03-05 16:16:35  ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-05 16:16:35  ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-05 16:16:35  ERROR: File "socket.pyc", line 283, in close
2019-03-05 16:16:35  ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-05 16:16:35  ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-05 16:16:35  ERROR: File "socket.pyc", line 307, in flush
2019-03-05 16:16:35  ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-05 16:16:35  ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:16:35  INFO: ----------------------------------------
2019-03-05 16:16:35  ERROR: File "socket.pyc", line 283, in close
2019-03-05 16:16:35  ERROR: File "socket.pyc", line 307, in flush
2019-03-05 16:16:35  ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:16:35  INFO: ----------------------------------------
2019-03-05 16:16:35  EVENT: HTTP.WsClientConnected [('192.168.1.101', 62398)]
2019-03-05 16:16:35  EVENT: MB.Run
2019-03-05 16:16:35     MACRO: MusicBee: Run MusicBee
2019-03-05 16:16:35        ACTION: MusicBee: Get "Is running": Stop macro if Never
2019-03-05 16:16:35        ACTION: If successful, jump to "Webserver: variables initialization"
2019-03-05 16:16:35           MACRO: Webserver: variables initialization
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Get "Is running": Stop macro if MusicBee is not running
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: Change Master Volume: 0.00 %
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Now playing command: Get artwork thumbnail: 128
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Player command: Get volume
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Player command: Get mute
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Now playing command: Get file tag: Album
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Now playing command: Get file tag: Artist
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Now playing command: Get file tag: TrackTitle
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Player command: Get play state
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Now playing command: Get file tag: Rating
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Now playing command: Get file tag: Lyricist
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Now playing command: Get track info
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Player command: Get shuffle
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Player command: Get repeat mode
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: MusicBee: Player command: Get "Stop after current enabled"
2019-03-05 16:16:35              ACTION: Get Mute Status
2019-03-05 16:16:35              ACTION: Webserver: Set temporary value
2019-03-05 16:16:35              ACTION: Webserver: Broadcast all values
2019-03-05 16:16:35              ACTION: Jump to "Webserver: Broadcast data: Playlist and Tracks"
2019-03-05 16:16:35                 MACRO: Webserver: Broadcast data: Playlist and Tracks
2019-03-05 16:16:35                    ACTION: MusicBee: Playlist command: Get playlists
2019-03-05 16:16:35                    ACTION: Webserver: Broadcast data: Playlists
2019-03-05 16:16:35                    ACTION: MusicBee: Playlist command: Get static playlists
2019-03-05 16:16:35                    ACTION: Webserver: Broadcast data: StaticPlaylists
2019-03-05 16:16:35                    ACTION: MusicBee: Now playing list command: Get tracks
2019-03-05 16:16:35                       NOTICE: Websocket closing: GOING_AWAY
2019-03-05 16:16:35                    ACTION: Webserver: Broadcast data: Tracks
2019-03-05 16:16:35  EVENT: HTTP.WsClientConnected [('192.168.1.101', 62399)]
2019-03-05 16:16:35  EVENT: MB.RegPosListener [('192.168.1.101', 62398)]
2019-03-05 16:16:35     MACRO: Webserver: Periodically broadcast data: Slider
2019-03-05 16:16:35        ACTION: Webserver: Stop all periodic tasks (broadcast type):
2019-03-05 16:16:35        ACTION: MusicBee: Get "Is running": Stop macro if MusicBee is not running
2019-03-05 16:16:35  EVENT: HTTP.WsClientDisconnected [('192.168.1.101', 62398)]
2019-03-05 16:16:37  EVENT: HTTP.WsClientConnected [('192.168.1.101', 62401)]
2019-03-05 16:16:37  EVENT: MB.Run
2019-03-05 16:16:37     MACRO: MusicBee: Run MusicBee
2019-03-05 16:16:37        ACTION: MusicBee: Get "Is running": Stop macro if Never
2019-03-05 16:16:37        ACTION: If successful, jump to "Webserver: variables initialization"
2019-03-05 16:16:37           MACRO: Webserver: variables initialization
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Get "Is running": Stop macro if MusicBee is not running
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: Change Master Volume: 0.00 %
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Now playing command: Get artwork thumbnail: 128
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Player command: Get volume
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Player command: Get mute
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Now playing command: Get file tag: Album
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Now playing command: Get file tag: Artist
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Now playing command: Get file tag: TrackTitle
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Player command: Get play state
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Now playing command: Get file tag: Rating
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Now playing command: Get file tag: Lyricist
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Now playing command: Get track info
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Player command: Get shuffle
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Player command: Get repeat mode
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: MusicBee: Player command: Get "Stop after current enabled"
2019-03-05 16:16:37              ACTION: Get Mute Status
2019-03-05 16:16:37              ACTION: Webserver: Set temporary value
2019-03-05 16:16:37              ACTION: Webserver: Broadcast all values
2019-03-05 16:16:37              ACTION: Jump to "Webserver: Broadcast data: Playlist and Tracks"
2019-03-05 16:16:37                 MACRO: Webserver: Broadcast data: Playlist and Tracks
2019-03-05 16:16:37                    ACTION: MusicBee: Playlist command: Get playlists
2019-03-05 16:16:37                    ACTION: Webserver: Broadcast data: Playlists
2019-03-05 16:16:37                    ACTION: MusicBee: Playlist command: Get static playlists
2019-03-05 16:16:37                    ACTION: Webserver: Broadcast data: StaticPlaylists
2019-03-05 16:16:37                    ACTION: MusicBee: Now playing list command: Get tracks
2019-03-05 16:16:37                    ACTION: Webserver: Broadcast data: Tracks
2019-03-05 16:17:24  EVENT: System.Idle
2019-03-05 16:17:27  NOTICE: Websocket closing: GOING_AWAY
2019-03-05 16:17:27  NOTICE: Websocket closing: GOING_AWAY
2019-03-05 16:17:27  EVENT: HTTP.WsClientDisconnected [('192.168.1.101', 62401)]
2019-03-05 16:17:27  EVENT: HTTP.WsClientDisconnected [('192.168.1.101', 62399)]
2019-03-05 16:17:27  EVENT: HTTP.WsClientConnected [('192.168.1.101', 62409)]
2019-03-05 16:17:27  ERROR: Webserver error /musicbee/css/style.css
2019-03-05 16:17:27  ERROR: Exception [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:17:27  ERROR: Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:17:27  ERROR: Webserver error /musicbee/css/jquery.alerts.css
2019-03-05 16:17:27  INFO: 
2019-03-05 16:17:27  ERROR: ----------------------------------------Exception [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:17:27  ERROR: Exception happened during processing of request from ('::ffff:192.168.1.101', 62414, 0, 0)Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:17:27  INFO: 
2019-03-05 16:17:27  ERROR: Traceback (most recent call last):
2019-03-05 16:17:27  INFO: ----------------------------------------
2019-03-05 16:17:27  ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-05 16:17:27  INFO: Exception happened during processing of request from ('::ffff:192.168.1.101', 62415, 0, 0)
2019-03-05 16:17:27  ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-05 16:17:27  ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-05 16:17:27  ERROR: Traceback (most recent call last):
2019-03-05 16:17:27  ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-05 16:17:27  ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-05 16:17:27  ERROR: File "socket.pyc", line 283, in close
2019-03-05 16:17:27  ERROR: File "socket.pyc", line 307, in flush
2019-03-05 16:17:27  ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:17:27  INFO: ----------------------------------------
2019-03-05 16:17:27  ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-05 16:17:27  ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-05 16:17:27  ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-05 16:17:27  ERROR: File "socket.pyc", line 283, in close
2019-03-05 16:17:27  ERROR: File "socket.pyc", line 307, in flush
2019-03-05 16:17:27  ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:17:27  INFO: ----------------------------------------
2019-03-05 16:17:27  NOTICE: Websocket closing: GOING_AWAY
2019-03-05 16:17:27  EVENT: HTTP.WsClientDisconnected [('192.168.1.101', 62409)]
2019-03-05 16:17:27  EVENT: HTTP.WsClientConnected [('192.168.1.101', 62416)]
2019-03-05 16:17:28  EVENT: MB.Run
2019-03-05 16:17:28     MACRO: MusicBee: Run MusicBee
2019-03-05 16:17:28        ACTION: MusicBee: Get "Is running": Stop macro if Never
2019-03-05 16:17:28        ACTION: If successful, jump to "Webserver: variables initialization"
2019-03-05 16:17:28           MACRO: Webserver: variables initialization
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Get "Is running": Stop macro if MusicBee is not running
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: Change Master Volume: 0.00 %
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Now playing command: Get artwork thumbnail: 128
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Player command: Get volume
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Player command: Get mute
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Now playing command: Get file tag: Album
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Now playing command: Get file tag: Artist
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Now playing command: Get file tag: TrackTitle
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Player command: Get play state
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Now playing command: Get file tag: Rating
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Now playing command: Get file tag: Lyricist
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Now playing command: Get track info
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Player command: Get shuffle
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Player command: Get repeat mode
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: MusicBee: Player command: Get "Stop after current enabled"
2019-03-05 16:17:28              ACTION: Get Mute Status
2019-03-05 16:17:28              ACTION: Webserver: Set temporary value
2019-03-05 16:17:28              ACTION: Webserver: Broadcast all values
2019-03-05 16:17:28              ACTION: Jump to "Webserver: Broadcast data: Playlist and Tracks"
2019-03-05 16:17:28                 MACRO: Webserver: Broadcast data: Playlist and Tracks
2019-03-05 16:17:28                    ACTION: MusicBee: Playlist command: Get playlists
2019-03-05 16:17:28                    ACTION: Webserver: Broadcast data: Playlists
2019-03-05 16:17:28                    ACTION: MusicBee: Playlist command: Get static playlists
2019-03-05 16:17:28                    ACTION: Webserver: Broadcast data: StaticPlaylists
2019-03-05 16:17:28                    ACTION: MusicBee: Now playing list command: Get tracks
2019-03-05 16:17:28                    ACTION: Webserver: Broadcast data: Tracks
2019-03-05 16:17:28  EVENT: HTTP.WsClientConnected [('192.168.1.101', 62417)]
2019-03-05 16:17:28  EVENT: MB.RegPosListener [('192.168.1.101', 62416)]
2019-03-05 16:17:28     MACRO: Webserver: Periodically broadcast data: Slider
2019-03-05 16:17:28        ACTION: Webserver: Stop all periodic tasks (broadcast type):
2019-03-05 16:17:28        ACTION: MusicBee: Get "Is running": Stop macro if MusicBee is not running
2019-03-05 16:18:13  NOTICE: Websocket closing: GOING_AWAY
2019-03-05 16:18:13  NOTICE: Websocket closing: GOING_AWAY
2019-03-05 16:18:13  EVENT: HTTP.WsClientDisconnected [('192.168.1.101', 62416)]
2019-03-05 16:18:13  EVENT: HTTP.WsClientDisconnected [('192.168.1.101', 62417)]
2019-03-05 16:18:13  ERROR: Webserver error /musicbee/css/style.css
2019-03-05 16:18:13  ERROR: Exception [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:18:13  ERROR: Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:18:13  INFO: ----------------------------------------
2019-03-05 16:18:13  INFO: Exception happened during processing of request from ('::ffff:192.168.1.101', 62455, 0, 0)
2019-03-05 16:18:13  ERROR: Traceback (most recent call last):
2019-03-05 16:18:13  ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-05 16:18:13  ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-05 16:18:13  ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-05 16:18:13  ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-05 16:18:13  ERROR: File "socket.pyc", line 283, in close
2019-03-05 16:18:13  ERROR: File "socket.pyc", line 307, in flush
2019-03-05 16:18:13  ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-05 16:18:13  INFO: ----------------------------------------
2019-03-05 16:18:13  EVENT: HTTP.WsClientConnected [('192.168.1.101', 62457)]
2019-03-05 16:18:13  EVENT: MB.Run
2019-03-05 16:18:13     MACRO: MusicBee: Run MusicBee
2019-03-05 16:18:13        ACTION: MusicBee: Get "Is running": Stop macro if Never
2019-03-05 16:18:13        ACTION: If successful, jump to "Webserver: variables initialization"
2019-03-05 16:18:13           MACRO: Webserver: variables initialization
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Get "Is running": Stop macro if MusicBee is not running
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: Change Master Volume: 0.00 %
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Now playing command: Get artwork thumbnail: 128
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Player command: Get volume
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Player command: Get mute
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Now playing command: Get file tag: Album
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Now playing command: Get file tag: Artist
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Now playing command: Get file tag: TrackTitle
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Player command: Get play state
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Now playing command: Get file tag: Rating
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Now playing command: Get file tag: Lyricist
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Now playing command: Get track info
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Player command: Get shuffle
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Player command: Get repeat mode
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: MusicBee: Player command: Get "Stop after current enabled"
2019-03-05 16:18:13              ACTION: Get Mute Status
2019-03-05 16:18:13              ACTION: Webserver: Set temporary value
2019-03-05 16:18:13              ACTION: Webserver: Broadcast all values
2019-03-05 16:18:13              ACTION: Jump to "Webserver: Broadcast data: Playlist and Tracks"
2019-03-05 16:18:13                 MACRO: Webserver: Broadcast data: Playlist and Tracks
2019-03-05 16:18:13                    ACTION: MusicBee: Playlist command: Get playlists
2019-03-05 16:18:13                    ACTION: Webserver: Broadcast data: Playlists
2019-03-05 16:18:14                    ACTION: MusicBee: Playlist command: Get static playlists
2019-03-05 16:18:14                    ACTION: Webserver: Broadcast data: StaticPlaylists
2019-03-05 16:18:14                    ACTION: MusicBee: Now playing list command: Get tracks
2019-03-05 16:18:14                    ACTION: Webserver: Broadcast data: Tracks
2019-03-05 16:18:14  EVENT: HTTP.WsClientConnected [('192.168.1.101', 62458)]
2019-03-05 16:18:14  EVENT: MB.RegPosListener [('192.168.1.101', 62457)]
2019-03-05 16:18:14     MACRO: Webserver: Periodically broadcast data: Slider
2019-03-05 16:18:14        ACTION: Webserver: Stop all
And here's the HTML:

Code: Select all

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=0">
<title>Home Control</title>
<style>
body {
	background-color:#eee;
}
.page {
	float:left;
}
.btngroup {
	margin:0 0 1.5em 0;
}
.tw-btn {
	width:70px;
	height:40px;
	float:left;
	border-radius:.5em;
	padding-left:5px;
	padding-right:5px;
	border-color:#888888;
	background-color:#eeeeee;
}
.tw-btn:focus {
	outline:none;
}
.tw-red {
	background-color:#ffeeee;
}
.tw-yel {
	background-color:#ffffcc;
}
.tw-grn {
	background-color:#eeffee;
}
.tw-brt {
	background-color:#f2f2f2;
}
.tw-dim {
	background-color:#cccccc;
}
.header, .footer {
	width:100%;
	background-color:#888;
	padding:1px;
}
.content {
	font-weight:bold;
}
.page {
	border:thin solid black;
	padding:8px;
	margin:5px;
}
h1, h2 {
	text-align:center;
	color:#fff;
	margin:8px;
}
.navbar {
	margin-bottom:0;
}
.navbtn {
	border:thin solid #777;
	border-radius:6px;
	background-color:#aaa;
	width:19%;
	text-align:center;
	float:left;
	color:#fff;
}
.stations {
	width:320px;
}
.stations ul {
	list-style: none;
}
.stations ul li {
	display:block;
	text-decoration:none;
	color:#000000;
	background-color:#FFFFFF;
	line-height:40px;
	font-family:Arial, Helvetica, sans-serif;
	font-size:15px;
	border-bottom-style:solid;
	border-bottom-width:1px;
	border-bottom-color:#aaaaaa;
	padding-left:10px;
	margin-left:-20px;
	cursor:pointer;
}
.stations ul li a strong {
	margin-right:10px;
}

#pandoraData a {
	text-decoration:none;
}
.songTitle {
	font-size:150%;
	font-weight:bold;
}
</style>

<script src="./scripts/jquery-2.1.4.min.js"></script>

<script type="text/javascript">

	//Setup websocket for EventGhost Webserver connections...
    wSocket = null;
    prot = "";
    ip = "";
    url = "";
	function init() {	//  event handlers for WebSocket:
		wSocket = null;
		prot = "";
		ip = location.host;
		if (location.protocol == "https:") {
			prot = "wss://";
		}
		else {
			prot = "ws://";
		}
		url = prot + ip + "/ws"; //mandatory for Tornado	//url = prot + ip; //enough for Webserver
		wSocket = new WebSocket(url);
		wSocket.onmessage = wsMessage;
	}
	function wsMessage(event) { //incoming message broadcasted or sent from webserver
		var d = new Date();
		var n = d.toLocaleTimeString(); 
		var obj = JSON.parse(event.data);
		if (getKeys([],obj)[2] == 'mailState') {
			if (obj.kwargs.mailState == 'OPEN') {
console.log('OPEN');				
				$("#mailbox .content").css('background-image','url("mailbox_open.gif")');
				document.getElementById("mailmsg").innerHTML = '<br /><br /><br />at ' + obj.kwargs.mailOTime;
				$("#mailbox").attr('OnClick', 'Trigger(this,"mailbox")');
				$('#mailsound audio')[0].play(); //one time
			} else if (obj.kwargs.mailState == 'CLOSED') {
				if ( obj.kwargs.mailNotify == 'ON') {
console.log('CLOSED and ON');				
					$("#mailbox .content").css('background-image','url("mailbox_flashing.gif")');
					document.getElementById("mailmsg").innerHTML = 'Mailbox Opened:<br />at ' + obj.kwargs.mailOTime + '<br /><span style="color:red;font-weight:bold">CHECK MAIL!</span>';
					$('#mailsound audio')[0].play(); //one time
					$("#mailbox").attr('OnClick', 'Trigger(this,"mailbox")');
				} else { //CLOSED and OFF
console.log('CLOSED and OFF');				
					document.getElementById("mailmsg").innerHTML = '';
					$("#mailbox .content").css('background-image','url("mailbox_monitoring.gif")');
					$("#mailbox").attr('OnClick', '');
				}
			}
		} else if (obj.method == "Data" && obj.dataName == "mailNotify") {
			$('#mailsound audio')[0].play(); //upon broadcast
//		} else if (obj.method == "Data" && obj.dataName == "keepAlive") {
//			console.log('keepalive: '+ event.data);
//			//$('#clicksound audio')[0].play(); //upon broadcast to keepAlive websocket
		}
	}

 

function openWebSocket(){
    if (wSocket.readyState === undefined || wSocket.readyState > 1) {
    	console.log('websocket down - restarting...');
    	init();
    }
}

$(function() {   //on Document Ready...
//    setInterval(openWebSocket, 5000);
	if ('{{mailState}}' == 'OPEN') {
console.log('PAGE LOAD: OPEN');	
		$("#mailbox .content").css('background-image','url("mailbox_open.gif")');
		document.getElementById("mailmsg").innerHTML = '<br /><br /><br />at {{mailOTime}}';
		$('#mailsound audio')[0].play(); //one time
		$("#mailbox").attr('OnClick', 'Trigger(this,"mailbox")');
	} else { //CLOSED
		if ( '{{mailNotify}}' == 'ON') {
console.log('PAGE LOAD: CLOSED and ON');	
			$("#mailbox .content").css('background-image','url("mailbox_flashing.gif")');
			document.getElementById("mailmsg").innerHTML = 'Mailbox Opened:<br />at {{mailOTime}}<br /><span style="color:red;font-weight:bold">CHECK MAIL!</span>';
			$('#mailsound audio')[0].play(); //one time
			$("#mailbox").attr('OnClick', 'Trigger(this,"mailbox")');
		} else { //OFF and CLOSED
console.log('PAGE LOAD: CLOSED and OFF');	
			$("#mailbox .content").css('background-image','url("mailbox_monitoring.gif")');
		}
	}
//setTimeout("location.reload(true);",300000); //reload page
	$(".navbar #all").css('background-color','#ddd');
	$(".navbar #all").css('color','#000');
	if (window.location.search.substring(1) == "size") {
		$("iframe").attr("width","340");
	    window.resizeTo(400,1250);
	    $('body').css('zoom','reset');
	};
	if ($(window).width() <= 360) { //phone is 360x640
		$("iframe").attr("width","340");
	    window.resizeTo(400,1250);
	    $('body').css('zoom','reset');
	};
	
});


function Trigger(elemt,eventname) //OnClicks
{
	$(elemt).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100); //blink the button
	if (eventname.substr(0,10) == 'gm-STATION') { //color the station button
		$('.stations li').css('background-color','white').css('color','black');
		$(elemt).css('background-color','#999').css('color','white');
	};
	if (eventname.substr(0,7) == 'gm-STOP') { // clear the station button colors
		$('.stations li').css('background-color','white').css('color','black');
	};
	var dateObject = new Date();
	$.post("index.html", eventname + "&_id" + dateObject.getTime()); //POST events to EventGhost webserver
console.log('POSTED:'+eventname + "&_id" + dateObject.getTime());
    return false;
}


$( ".navbtn" ).click(function() { //Navigation
	$(".navbtn").css('background-color','#aaa');
	$(".navbtn").css('color','#fff');
	var group = $(this).attr('id');
	$(".navbtn#" + group).css('background-color','#ddd');
	$(".navbtn#" + group).css('color','#000');
	if(group == 'all') {
		$(".page").css('display','block');
	} else {
		$(".page").css('display','none');
		$(".page#" + group).css('display','block');
	};


});

var getKeys = function(previousKeys,obj){ //gets key names from JSON objects/arrays
    var currentKeys = Object.keys(obj);
    previousKeys = previousKeys.concat(currentKeys);
    for(var i=0;i<currentKeys.length;i++){
        var innerObj = obj[currentKeys[i]];
        if(innerObj!==null && typeof innerObj === 'object' && !Array.isArray(innerObj)){
        return this.getKeys(previousKeys,innerObj);
        }
    }
    return previousKeys;
    //usage: getKeys([],obj)[2] would evaluate to the third key name in obj
}

//Routine to read extracted pandora.txt track info and display it
var data = '';
var last = '';
setInterval(function(){
	var dt = new Date();
	var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
	$("h1").text(time);
/*
	$('#pandoraTemp').load("pandora.txt?t=" + time); //time forces reload, not cached version
	data = $('#pandoraTemp').html();
	pos = data.indexOf("|"); //# characters before | (timestamp)
	last = data.substr(0,pos);
	mesg = 'STATION: ' + data.substr(pos+1);
	now  = Date.now();
	if (now - last > 600000) // if pandora file older than 10 minutes ago
		mesg = '(No Internet music playing now)<br /> ';

	if (doesFileExist("http://192.168.1.105:48888/pandora_image.jpg")) {
		mesg = 'Now Playing:<br /><img id="pandoraImage" width="300px" src="pandora_image.jpg?random='+new Date().getTime()+'" />';
	} else {
		mesg = '<img id="pandoraImage" width="300px" src="blank.png" />';
	}
	$("#pandoraData").html(mesg);
	$("#pandoraData").show();
*/	
},10000);

/*
function doesFileExist(urlToFile) {
    var xhr = new XMLHttpRequest();
    xhr.open('HEAD', urlToFile, false);
    xhr.send();
     if (xhr.status == "404") {
        return false;
    } else {
        return true;
    }
}
*/

</script>

</head>
<body zoom="100%" onload="init()" />
<div class="header">
  <div style="float:right"><a href="simple_list.html"><button>LIST</button></a></div>
  <div style="float:right"><a href="index.html" download><button>EDIT</button></a></div>
  <h1>HTPC Home</h1>
</div>

<div class="navbar">

<!--
  <div class="navbtn" id="all">
    <h4>ALL</h4>
  </div>
  <div class="navbtn" id="x10">
    <h4>X10</h4>
  </div>
  <div class="navbtn" id="htpc">
    <h4>HTPC</h4>
  </div>
  <div class="navbtn" id="radio">
    <h4>RADIO</h4>
  </div>
  <div class="navbtn" id="mp3">
    <h4>MP3 MUSIC</h4>
  </div>
-->	
  
<!--
    <a id="homelink" href="index.html">HOME</a>
    <a id="musicbee" href="./musicbee/index.html">MUSIC</a>
        <ul>
            <li><a href="#x10">X10 Controls</a></li>
            <li><a href="#htpc">Home Theater Controls</a></li>
        </ul>
--> 
</div>

<div style='float:left;display:none;' id='pandoraTemp'></div>

<div class="page" id="mailbox">
    <div class="content" id="mailmsg" style="width:130px;height:65px;background-repeat:no-repeat;padding:5px 10px;">
    </div>
    <div id="status"> </div>
<!--	<span id="clicksound"><audio><source src='./softbeep.wav'  type='audio/wav' /></audio></span>  -->
	<span id="mailsound"><audio><source src='./checkmailbox.wav'  type='audio/wav' /></audio></span>
</div>

<div class="page" id="x10">
  <div class="content">
    <h3>X10 Controls</h3>
    <div style="float:left;margin:0 1em 1em 0">1 Living Room<br />
      <button  OnClick="Trigger(this,'x10-1on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button  OnClick="Trigger(this,'x10-1off')" class="tw-btn tw-red">OFF</button>
    </div>
    <div style="float:left;margin:0 1em 1em 0">2 Front Entry<br />
      <button  OnClick="Trigger(this,'x10-2on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button OnClick="Trigger(this,'x10-2off')" class="tw-btn tw-red">OFF</button>
    </div>
    <div style="float:left;margin:0 1em 1em 0">3 West Lawn<br />
      <button OnClick="Trigger(this,'x10-3on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button OnClick="Trigger(this,'x10-3off')" class="tw-btn tw-red">OFF</button>
    </div>
    <div style="float:left;margin:0 1em 1em 0">4 BBQ & Decks<br />
      <button  OnClick="Trigger(this,'x10-4on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button  OnClick="Trigger(this,'x10-4off')" class="tw-btn tw-red">OFF</button>
    </div>
    <div style="float:left;margin:0 1em 1em 0">5 Sue Office<br />
      <button  OnClick="Trigger(this,'x10-5on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button OnClick="Trigger(this,'x10-5off')" class="tw-btn tw-red">OFF</button>
    </div>
    <div style="float:left;margin:0 1em 1em 0">6 Sue Music<br />
      <button OnClick="Trigger(this,'x10-6on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button OnClick="Trigger(this,'x10-6off')" class="tw-btn tw-red">OFF</button>
    </div>
    <div style="float:left;margin:0 1em 1em 0">7 Deck Music<br />
      <button  OnClick="Trigger(this,'x10-7on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button  OnClick="Trigger(this,'x10-7off')" class="tw-btn tw-red">OFF</button>
    </div>
    <!--
		<div style="float:left;margin:0 1em 1em 0">8 Dining Room<br /><button  OnClick="Trigger(this,'x10-8on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button><button OnClick="Trigger(this,'x10-8off')" class="tw-btn tw-red">OFF</button></div>
-->
    <div style="float:left;margin:0 1em 1em 0">8 Pool Lights<br />
      <button OnClick="Trigger(this,'x10-8on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button OnClick="Trigger(this,'x10-8off')" class="tw-btn tw-red">OFF</button>
    </div>
    <div style="float:left;margin:0 1em 1em 0">9 Cab & Candles<br />
      <button OnClick="Trigger(this,'x10-9on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button OnClick="Trigger(this,'x10-9off')" class="tw-btn tw-red">OFF</button>
    </div>
    <!--
		<div style="float:left;margin:0 1em 1em 0">10 LivRm Lite (slow)<br /><button  OnClick="Trigger(this,'x10-10on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button><button  OnClick="Trigger(this,'x10-10off')" class="tw-btn tw-red">OFF</button></div>
-->
    <div style="float:left;margin:0 1em 1em 0">11 Fan LivRm<br />
      <button  OnClick="Trigger(this,'x10-11on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button OnClick="Trigger(this,'x10-11off')" class="tw-btn tw-red">OFF</button>
    </div>
    <div style="float:left;margin:0 1em 1em 0">12 Fan Kitchen<br />
      <button OnClick="Trigger(this,'x10-12on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button OnClick="Trigger(this,'x10-12off')" class="tw-btn tw-red">OFF</button>
    </div>
    <!--
		<div style="float:left;margin:0 1em 1em 0">9<br /><button OnClick="Trigger(this,'x10-13on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button><button OnClick="Trigger(this,'x10-13off')" class="tw-btn tw-red">OFF</button></div>
		<div style="float:left;margin:0 1em 1em 0">10<br /><button  OnClick="Trigger(this,'x10-14on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button><button  OnClick="Trigger(this,'x10-14off')" class="tw-btn tw-red">OFF</button></div>
-->
		<div style="float:left;margin:0 1em 1em 0">13<br /><button  OnClick="Trigger(this,'x10-13on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button><button OnClick="Trigger(this,'x10-13off')" class="tw-btn tw-red">OFF</button></div>
		<div style="float:left;margin:0 1em 1em 0">14<br /><button OnClick="Trigger(this,'x10-14on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button><button OnClick="Trigger(this,'x10-14off')" class="tw-btn tw-red">OFF</button></div>

    <div style="float:left;margin:0 1em 1em 0">Dimmer<br />
      <button  OnClick="Trigger(this,'x10-bright')"  class="tw-btn tw-brt" style="background-color:#fafafa">&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;</button>
      <button OnClick="Trigger(this,'x10-dim')" class="tw-btn tw-dim">&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;</button>
    </div>
    <div style="float:left;margin:0 1em 1em 0">ALL<br />
      <button OnClick="Trigger(this,'x10-allon')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
      <button OnClick="Trigger(this,'x10-alloff')" class="tw-btn tw-red">OFF</button>
    </div>
  </div>
</div>

<div class="page" id="htpc">
  <div class="content">
    <h3>HTPC Controls</h3>
    <div class="btngroup">Projector / Screen:<br />
      <button OnClick="Trigger(this,'htpc-proj-off')" class="tw-btn tw-red">OFF</button>
      <button OnClick="Trigger(this,'htpc-proj-on')" class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
    </div>
    <br />
    <br />
    <div class="btngroup">Sound Source:<br />
      <button OnClick="Trigger(this,'htpc-source-off')" class="tw-btn tw-dim">&nbsp;OFF&nbsp;</button>
      <button OnClick="Trigger(this,'htpc-source-dish')" class="tw-btn tw-grn">Dish</button>
      <button OnClick="Trigger(this,'htpc-source-nuc')" class="tw-btn tw-grn">NUC</button>
      <button OnClick="Trigger(this,'htpc-source-cast')" class="tw-btn tw-grn">Cast</button>
      <button OnClick="Trigger(this,'htpc-source-cast-audio')" class="tw-btn tw-grn">Cast<br />Audio</button>
    </div>
    <br />
    <br />
    <div class="btngroup">Volume:<br />
      <button OnClick="Trigger(this,'htpc-volume-mute')" class="tw-btn tw-dim">MUTE</button>
      <button OnClick="Trigger(this,'htpc-volume-down')" class="tw-btn tw-red">&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;</button>
      <button OnClick="Trigger(this,'htpc-volume-up')" class="tw-btn tw-grn">&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;</button>
    </div>
    <br />
    <br />
    <div class="btngroup">Sue Music Amplifier:<br />
      <button OnClick="Trigger(this,'x10-6off')" class="tw-btn tw-red">OFF</button>
      <button OnClick="Trigger(this,'x10-6on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button>
    </div>
    <br />
    <br />
  </div>
</div>

<div class="page" id="radio" style="display:block">
    <div class="btngroup stations"><h3>Pandora Music Stations:</h3>      <ul>
		<div style='display:none;float:left;margin:0 0 10px -20px;border-bottom:1px solid #000;' id='pandoraData'></div>
        <li OnClick="Trigger(this,'gm-STATION0')">Beegee Adair Dinner Piano</li>
        <li OnClick="Trigger(this,'gm-STATION1')">Cool Jazz</li>
        <li OnClick="Trigger(this,'gm-STATION10')">Solo Piano</li>
        <li OnClick="Trigger(this,'gm-STATION2')">Classical Commute</li>
        <li OnClick="Trigger(this,'gm-STATION3')">Classic Broadway Showtunes</li>
        <li OnClick="Trigger(this,'gm-STATION11')">Lite Rock Songwriters</li>
        <li OnClick="Trigger(this,'gm-STATION4')">So Into You</li>
        <li OnClick="Trigger(this,'gm-STATION5')">Steely Dan</li>
        <li OnClick="Trigger(this,'gm-STATION6')">60s, 70s &80s Hits</li>
        <li OnClick="Trigger(this,'gm-STATION7')">Oldies Station</li>
        <li OnClick="Trigger(this,'gm-STATION8')">Classic Rock</li>
        <li OnClick="Trigger(this,'gm-STATION9')">Classic Country</li>
		<li OnClick="Trigger(this,'gm-STATION12')">Timothy B Schmit Station</li>
		<li OnClick="Trigger(this,'gm-STATION13')">Ben Sidran Station</li>
     
<!-- GOOGLE PLAY stations:
        <li OnClick="Trigger(this,'gm-STATION1')">Solo Jazz Guitar</li>
        <li OnClick="Trigger(this,'gm-STATION2')">Peaceful Easy Feeling</li>
        <li OnClick="Trigger(this,'gm-STATION3')">Steely Dan Radio</li>
        <li OnClick="Trigger(this,'gm-STATION4')">A New Age Spa Day</li>
        <li OnClick="Trigger(this,'gm-STATION5')">The Ultimate Oldies Party</li>
        <li OnClick="Trigger(this,'gm-STATION6')">Classic Rock's Greatest Hits</li>
        <li OnClick="Trigger(this,'gm-STATION7')">Crosby & Nash Radio</li>
        <li OnClick="Trigger(this,'gm-STATION8')">Lounge Instrumentals</li>
-->
      </ul>
      <button OnClick="Trigger(this,'gm-PAUSE')"  class="tw-btn tw-yel">Pause</button>
      <button OnClick="Trigger(this,'gm-NEXT')" class="tw-btn tw-grn">Skip</button>
      <button OnClick="Trigger(this,'gm-STOP')" class="tw-btn tw-red">Stop</button>
    </div>
</div>

<div class="page" id="mp3">
  <div class="content">
    <h3>NUC MP3 Music Controls</h3>
    <iframe src='musicbee/index.html' frameborder='0' scrolling="yes" width='500' height='600'> </iframe>
  </div>
</div>

<div class="footer" style="clear:left">
  <h2>Wysocki Home Control System</h2>
</div>

</body>
</html>

User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Webserver

Post by yokel22 » Wed Mar 06, 2019 4:03 pm

It's something in the javascript that's handling the socket connection to the webserver plugin. Each time you load/refresh the page it's killing/creating a new sicket connection. You can test this by using a blank html page & load the page. If you don't see those errors that's what's going on.

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

Re: Webserver

Post by kgschlosser » Wed Mar 06, 2019 5:39 pm

this is what is doing it.

Code: Select all


$(function() {   //on Document Ready...
//    setInterval(openWebSocket, 5000);
	if ('{{mailState}}' == 'OPEN') {
console.log('PAGE LOAD: OPEN');	
		$("#mailbox .content").css('background-image','url("mailbox_open.gif")');
		document.getElementById("mailmsg").innerHTML = '<br /><br /><br />at {{mailOTime}}';
		$('#mailsound audio')[0].play(); //one time
		$("#mailbox").attr('OnClick', 'Trigger(this,"mailbox")');
	} else { //CLOSED
		if ( '{{mailNotify}}' == 'ON') {
console.log('PAGE LOAD: CLOSED and ON');	
			$("#mailbox .content").css('background-image','url("mailbox_flashing.gif")');
			document.getElementById("mailmsg").innerHTML = 'Mailbox Opened:<br />at {{mailOTime}}<br /><span style="color:red;font-weight:bold">CHECK MAIL!</span>';
			$('#mailsound audio')[0].play(); //one time
			$("#mailbox").attr('OnClick', 'Trigger(this,"mailbox")');
		} else { //OFF and CLOSED
console.log('PAGE LOAD: CLOSED and OFF');	
			$("#mailbox .content").css('background-image','url("mailbox_monitoring.gif")');
		}
	}
each and every time you load the page you create a new websocket connection (this includes refreshes) But you are not gracefully closing the socket all.

give this a shot and see if it solves the problem.

Code: Select all

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1,user-scalable=0">
    <title>Home Control</title>
    <style>
        body {
            background-color: #eee;
        }

        .page {
            float: left;
        }

        .btngroup {
            margin: 0 0 1.5em 0;
        }

        .tw-btn {
            width: 70px;
            height: 40px;
            float: left;
            border-radius: .5em;
            padding-left: 5px;
            padding-right: 5px;
            border-color: #888888;
            background-color: #eeeeee;
        }

        .tw-btn:focus {
            outline: none;
        }

        .tw-red {
            background-color: #ffeeee;
        }

        .tw-yel {
            background-color: #ffffcc;
        }

        .tw-grn {
            background-color: #eeffee;
        }

        .tw-brt {
            background-color: #f2f2f2;
        }

        .tw-dim {
            background-color: #cccccc;
        }

        .header, .footer {
            width: 100%;
            background-color: #888;
            padding: 1px;
        }

        .content {
            font-weight: bold;
        }

        .page {
            border: thin solid black;
            padding: 8px;
            margin: 5px;
        }

        h1, h2 {
            text-align: center;
            color: #fff;
            margin: 8px;
        }

        .navbar {
            margin-bottom: 0;
        }

        .navbtn {
            border: thin solid #777;
            border-radius: 6px;
            background-color: #aaa;
            width: 19%;
            text-align: center;
            float: left;
            color: #fff;
        }

        .stations {
            width: 320px;
        }

        .stations ul {
            list-style: none;
        }

        .stations ul li {
            display: block;
            text-decoration: none;
            color: #000000;
            background-color: #FFFFFF;
            line-height: 40px;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 15px;
            border-bottom-style: solid;
            border-bottom-width: 1px;
            border-bottom-color: #aaaaaa;
            padding-left: 10px;
            margin-left: -20px;
            cursor: pointer;
        }

        .stations ul li a strong {
            margin-right: 10px;
        }

        #pandoraData a {
            text-decoration: none;
        }

        .songTitle {
            font-size: 150%;
            font-weight: bold;
        }
    </style>

    <script src="./scripts/jquery-2.1.4.min.js"></script>

    <script type="text/javascript">

        //Setup websocket for EventGhost Webserver connections...
        wSocket = null;
        prot = "";
        ip = "";
        url = "";
        
        function openWebSocket() {
            ip = location.host;
            if (location.protocol == "https:") {
                prot = "wss://";
            }
            else {
                prot = "ws://";
            }
            
            url = prot + ip + "/ws"; //mandatory for Tornado	//url = prot + ip; //enough for Webserver
            wSocket = new WebSocket(url);
            wSocket.onmessage = wsMessage;
            window.onunload = function () {
                wSocket.close();
            }
        }

        function init() {	//  event handlers for WebSocket:
            openWebSocket();
        }

        function wsMessage(event) { //incoming message broadcasted or sent from webserver
            var d = new Date();
            var n = d.toLocaleTimeString();
            var obj = JSON.parse(event.data);
            if (getKeys([], obj)[2] == 'mailState') {
                if (obj.kwargs.mailState == 'OPEN') {
                    console.log('OPEN');
                    $("#mailbox .content").css('background-image', 'url("mailbox_open.gif")');
                    document.getElementById("mailmsg").innerHTML = '<br /><br /><br />at ' + obj.kwargs.mailOTime;
                    $("#mailbox").attr('OnClick', 'Trigger(this,"mailbox")');
                    $('#mailsound audio')[0].play(); //one time
                } else if (obj.kwargs.mailState == 'CLOSED') {
                    if (obj.kwargs.mailNotify == 'ON') {
                        console.log('CLOSED and ON');
                        $("#mailbox .content").css('background-image', 'url("mailbox_flashing.gif")');
                        document.getElementById("mailmsg").innerHTML = 'Mailbox Opened:<br />at ' + obj.kwargs.mailOTime + '<br /><span style="color:red;font-weight:bold">CHECK MAIL!</span>';
                        $('#mailsound audio')[0].play(); //one time
                        $("#mailbox").attr('OnClick', 'Trigger(this,"mailbox")');
                    } else { //CLOSED and OFF
                        console.log('CLOSED and OFF');
                        document.getElementById("mailmsg").innerHTML = '';
                        $("#mailbox .content").css('background-image', 'url("mailbox_monitoring.gif")');
                        $("#mailbox").attr('OnClick', '');
                    }
                }
            } else if (obj.method == "Data" && obj.dataName == "mailNotify") {
                $('#mailsound audio')[0].play(); //upon broadcast
//		} else if (obj.method == "Data" && obj.dataName == "keepAlive") {
//			console.log('keepalive: '+ event.data);
//			//$('#clicksound audio')[0].play(); //upon broadcast to keepAlive websocket
            }
        }
        
        function checkWebsocket() {
            if (wSocket.readyState === undefined || wSocket.readyState > 1) {
                console.log('websocket down - restarting...');
                openWebsocket();

            }
        }
        
        $(function () {   //on Document Ready...
//    setInterval(openWebSocket, 5000);
            if ('{{mailState}}' == 'OPEN') {
                console.log('PAGE LOAD: OPEN');
                $("#mailbox .content").css('background-image', 'url("mailbox_open.gif")');
                document.getElementById("mailmsg").innerHTML = '<br /><br /><br />at {{mailOTime}}';
                $('#mailsound audio')[0].play(); //one time
                $("#mailbox").attr('OnClick', 'Trigger(this,"mailbox")');
            } else { //CLOSED
                if ('{{mailNotify}}' == 'ON') {
                    console.log('PAGE LOAD: CLOSED and ON');
                    $("#mailbox .content").css('background-image', 'url("mailbox_flashing.gif")');
                    document.getElementById("mailmsg").innerHTML = 'Mailbox Opened:<br />at {{mailOTime}}<br /><span style="color:red;font-weight:bold">CHECK MAIL!</span>';
                    $('#mailsound audio')[0].play(); //one time
                    $("#mailbox").attr('OnClick', 'Trigger(this,"mailbox")');
                } else { //OFF and CLOSED
                    console.log('PAGE LOAD: CLOSED and OFF');
                    $("#mailbox .content").css('background-image', 'url("mailbox_monitoring.gif")');
                }
            }
//setTimeout("location.reload(true);",300000); //reload page
            $(".navbar #all").css('background-color', '#ddd');
            $(".navbar #all").css('color', '#000');
            if (window.location.search.substring(1) == "size") {
                $("iframe").attr("width", "340");
                window.resizeTo(400, 1250);
                $('body').css('zoom', 'reset');
            }
            if ($(window).width() <= 360) { //phone is 360x640
                $("iframe").attr("width", "340");
                window.resizeTo(400, 1250);
                $('body').css('zoom', 'reset');
            }

        });


        function Trigger(elemt, eventname) { //OnClick
            $(elemt).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100); //blink the button
            if (eventname.substr(0, 10) == 'gm-STATION') { //color the station button
                $('.stations li').css('background-color', 'white').css('color', 'black');
                $(elemt).css('background-color', '#999').css('color', 'white');
            }
            if (eventname.substr(0, 7) == 'gm-STOP') { // clear the station button colors
                $('.stations li').css('background-color', 'white').css('color', 'black');
            }
            var dateObject = new Date();
            $.post("index.html", eventname + "&_id" + dateObject.getTime()); //POST events to EventGhost webserver
            console.log('POSTED:' + eventname + "&_id" + dateObject.getTime());
            return false;
        }


        $(".navbtn").click(function () { //Navigation
            $(".navbtn").css('background-color', '#aaa');
            $(".navbtn").css('color', '#fff');
            var group = $(this).attr('id');
            $(".navbtn#" + group).css('background-color', '#ddd');
            $(".navbtn#" + group).css('color', '#000');
            if (group == 'all') {
                $(".page").css('display', 'block');
            } else {
                $(".page").css('display', 'none');
                $(".page#" + group).css('display', 'block');
            }
        });

        var getKeys = function (previousKeys, obj) { //gets key names from JSON objects/arrays
            var currentKeys = Object.keys(obj);
            previousKeys = previousKeys.concat(currentKeys);
            for (var i = 0; i < currentKeys.length; i++) {
                var innerObj = obj[currentKeys[i]];
                if (innerObj !== null && typeof innerObj === 'object' && !Array.isArray(innerObj)) {
                    return this.getKeys(previousKeys, innerObj);
                }
            }
            return previousKeys;
            //usage: getKeys([],obj)[2] would evaluate to the third key name in obj
        };

        //Routine to read extracted pandora.txt track info and display it
        var data = '';
        var last = '';
        setInterval(function () {
            var dt = new Date();
            var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
            $("h1").text(time);
            /*
                $('#pandoraTemp').load("pandora.txt?t=" + time); //time forces reload, not cached version
                data = $('#pandoraTemp').html();
                pos = data.indexOf("|"); //# characters before | (timestamp)
                last = data.substr(0,pos);
                mesg = 'STATION: ' + data.substr(pos+1);
                now  = Date.now();
                if (now - last > 600000) // if pandora file older than 10 minutes ago
                    mesg = '(No Internet music playing now)<br /> ';

                if (doesFileExist("http://192.168.1.105:48888/pandora_image.jpg")) {
                    mesg = 'Now Playing:<br /><img id="pandoraImage" width="300px" src="pandora_image.jpg?random='+new Date().getTime()+'" />';
                } else {
                    mesg = '<img id="pandoraImage" width="300px" src="blank.png" />';
                }
                $("#pandoraData").html(mesg);
                $("#pandoraData").show();
            */
        }, 10000);

        /*
        function doesFileExist(urlToFile) {
            var xhr = new XMLHttpRequest();
            xhr.open('HEAD', urlToFile, false);
            xhr.send();
             if (xhr.status == "404") {
                return false;
            } else {
                return true;
            }
        }
        */

    </script>

</head>
<body zoom="100%" onload="init()"/>
<div class="header">
    <div style="float:right"><a href="simple_list.html">
        <button>LIST</button>
    </a></div>
    <div style="float:right"><a href="index.html" download>
        <button>EDIT</button>
    </a></div>
    <h1>HTPC Home</h1>
</div>

<div class="navbar">

    <!--
      <div class="navbtn" id="all">
        <h4>ALL</h4>
      </div>
      <div class="navbtn" id="x10">
        <h4>X10</h4>
      </div>
      <div class="navbtn" id="htpc">
        <h4>HTPC</h4>
      </div>
      <div class="navbtn" id="radio">
        <h4>RADIO</h4>
      </div>
      <div class="navbtn" id="mp3">
        <h4>MP3 MUSIC</h4>
      </div>
    -->

    <!--
        <a id="homelink" href="index.html">HOME</a>
        <a id="musicbee" href="./musicbee/index.html">MUSIC</a>
            <ul>
                <li><a href="#x10">X10 Controls</a></li>
                <li><a href="#htpc">Home Theater Controls</a></li>
            </ul>
    -->
</div>

<div style='float:left;display:none;' id='pandoraTemp'></div>

<div class="page" id="mailbox">
    <div class="content" id="mailmsg"
         style="width:130px;height:65px;background-repeat:no-repeat;padding:5px 10px;">
    </div>
    <div id="status"></div>
    <!--	<span id="clicksound"><audio><source src='./softbeep.wav'  type='audio/wav' /></audio></span>  -->
    <span id="mailsound"><audio><source src='./checkmailbox.wav'
                                        type='audio/wav'/></audio></span>
</div>

<div class="page" id="x10">
    <div class="content">
        <h3>X10 Controls</h3>
        <div style="float:left;margin:0 1em 1em 0">1 Living Room<br/>
            <button OnClick="Trigger(this,'x10-1on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-1off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <div style="float:left;margin:0 1em 1em 0">2 Front Entry<br/>
            <button OnClick="Trigger(this,'x10-2on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-2off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <div style="float:left;margin:0 1em 1em 0">3 West Lawn<br/>
            <button OnClick="Trigger(this,'x10-3on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-3off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <div style="float:left;margin:0 1em 1em 0">4 BBQ & Decks<br/>
            <button OnClick="Trigger(this,'x10-4on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-4off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <div style="float:left;margin:0 1em 1em 0">5 Sue Office<br/>
            <button OnClick="Trigger(this,'x10-5on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-5off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <div style="float:left;margin:0 1em 1em 0">6 Sue Music<br/>
            <button OnClick="Trigger(this,'x10-6on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-6off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <div style="float:left;margin:0 1em 1em 0">7 Deck Music<br/>
            <button OnClick="Trigger(this,'x10-7on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-7off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <!--
            <div style="float:left;margin:0 1em 1em 0">8 Dining Room<br /><button  OnClick="Trigger(this,'x10-8on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button><button OnClick="Trigger(this,'x10-8off')" class="tw-btn tw-red">OFF</button></div>
    -->
        <div style="float:left;margin:0 1em 1em 0">8 Pool Lights<br/>
            <button OnClick="Trigger(this,'x10-8on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-8off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <div style="float:left;margin:0 1em 1em 0">9 Cab & Candles<br/>
            <button OnClick="Trigger(this,'x10-9on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-9off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <!--
            <div style="float:left;margin:0 1em 1em 0">10 LivRm Lite (slow)<br /><button  OnClick="Trigger(this,'x10-10on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button><button  OnClick="Trigger(this,'x10-10off')" class="tw-btn tw-red">OFF</button></div>
    -->
        <div style="float:left;margin:0 1em 1em 0">11 Fan LivRm<br/>
            <button OnClick="Trigger(this,'x10-11on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-11off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <div style="float:left;margin:0 1em 1em 0">12 Fan Kitchen<br/>
            <button OnClick="Trigger(this,'x10-12on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-12off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <!--
            <div style="float:left;margin:0 1em 1em 0">9<br /><button OnClick="Trigger(this,'x10-13on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button><button OnClick="Trigger(this,'x10-13off')" class="tw-btn tw-red">OFF</button></div>
            <div style="float:left;margin:0 1em 1em 0">10<br /><button  OnClick="Trigger(this,'x10-14on')"  class="tw-btn tw-grn">&nbsp;ON&nbsp;</button><button  OnClick="Trigger(this,'x10-14off')" class="tw-btn tw-red">OFF</button></div>
    -->
        <div style="float:left;margin:0 1em 1em 0">13<br/>
            <button OnClick="Trigger(this,'x10-13on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-13off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
        <div style="float:left;margin:0 1em 1em 0">14<br/>
            <button OnClick="Trigger(this,'x10-14on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-14off')" class="tw-btn tw-red">
                OFF
            </button>
        </div>

        <div style="float:left;margin:0 1em 1em 0">Dimmer<br/>
            <button OnClick="Trigger(this,'x10-bright')" class="tw-btn tw-brt"
                    style="background-color:#fafafa">&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-dim')" class="tw-btn tw-dim">
                &nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;
            </button>
        </div>
        <div style="float:left;margin:0 1em 1em 0">ALL<br/>
            <button OnClick="Trigger(this,'x10-allon')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
            <button OnClick="Trigger(this,'x10-alloff')" class="tw-btn tw-red">
                OFF
            </button>
        </div>
    </div>
</div>

<div class="page" id="htpc">
    <div class="content">
        <h3>HTPC Controls</h3>
        <div class="btngroup">Projector / Screen:<br/>
            <button OnClick="Trigger(this,'htpc-proj-off')"
                    class="tw-btn tw-red">OFF
            </button>
            <button OnClick="Trigger(this,'htpc-proj-on')"
                    class="tw-btn tw-grn">&nbsp;ON&nbsp;
            </button>
        </div>
        <br/>
        <br/>
        <div class="btngroup">Sound Source:<br/>
            <button OnClick="Trigger(this,'htpc-source-off')"
                    class="tw-btn tw-dim">&nbsp;OFF&nbsp;
            </button>
            <button OnClick="Trigger(this,'htpc-source-dish')"
                    class="tw-btn tw-grn">Dish
            </button>
            <button OnClick="Trigger(this,'htpc-source-nuc')"
                    class="tw-btn tw-grn">NUC
            </button>
            <button OnClick="Trigger(this,'htpc-source-cast')"
                    class="tw-btn tw-grn">Cast
            </button>
            <button OnClick="Trigger(this,'htpc-source-cast-audio')"
                    class="tw-btn tw-grn">Cast<br/>Audio
            </button>
        </div>
        <br/>
        <br/>
        <div class="btngroup">Volume:<br/>
            <button OnClick="Trigger(this,'htpc-volume-mute')"
                    class="tw-btn tw-dim">MUTE
            </button>
            <button OnClick="Trigger(this,'htpc-volume-down')"
                    class="tw-btn tw-red">&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;
            </button>
            <button OnClick="Trigger(this,'htpc-volume-up')"
                    class="tw-btn tw-grn">&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;
            </button>
        </div>
        <br/>
        <br/>
        <div class="btngroup">Sue Music Amplifier:<br/>
            <button OnClick="Trigger(this,'x10-6off')" class="tw-btn tw-red">
                OFF
            </button>
            <button OnClick="Trigger(this,'x10-6on')" class="tw-btn tw-grn">
                &nbsp;ON&nbsp;
            </button>
        </div>
        <br/>
        <br/>
    </div>
</div>

<div class="page" id="radio" style="display:block">
    <div class="btngroup stations"><h3>Pandora Music Stations:</h3>
        <ul>
            <div style='display:none;float:left;margin:0 0 10px -20px;border-bottom:1px solid #000;'
                 id='pandoraData'></div>
            <li OnClick="Trigger(this,'gm-STATION0')">Beegee Adair Dinner
                Piano
            </li>
            <li OnClick="Trigger(this,'gm-STATION1')">Cool Jazz</li>
            <li OnClick="Trigger(this,'gm-STATION10')">Solo Piano</li>
            <li OnClick="Trigger(this,'gm-STATION2')">Classical Commute</li>
            <li OnClick="Trigger(this,'gm-STATION3')">Classic Broadway
                Showtunes
            </li>
            <li OnClick="Trigger(this,'gm-STATION11')">Lite Rock Songwriters
            </li>
            <li OnClick="Trigger(this,'gm-STATION4')">So Into You</li>
            <li OnClick="Trigger(this,'gm-STATION5')">Steely Dan</li>
            <li OnClick="Trigger(this,'gm-STATION6')">60s, 70s &80s Hits</li>
            <li OnClick="Trigger(this,'gm-STATION7')">Oldies Station</li>
            <li OnClick="Trigger(this,'gm-STATION8')">Classic Rock</li>
            <li OnClick="Trigger(this,'gm-STATION9')">Classic Country</li>
            <li OnClick="Trigger(this,'gm-STATION12')">Timothy B Schmit
                Station
            </li>
            <li OnClick="Trigger(this,'gm-STATION13')">Ben Sidran Station</li>

            <!-- GOOGLE PLAY stations:
                    <li OnClick="Trigger(this,'gm-STATION1')">Solo Jazz Guitar</li>
                    <li OnClick="Trigger(this,'gm-STATION2')">Peaceful Easy Feeling</li>
                    <li OnClick="Trigger(this,'gm-STATION3')">Steely Dan Radio</li>
                    <li OnClick="Trigger(this,'gm-STATION4')">A New Age Spa Day</li>
                    <li OnClick="Trigger(this,'gm-STATION5')">The Ultimate Oldies Party</li>
                    <li OnClick="Trigger(this,'gm-STATION6')">Classic Rock's Greatest Hits</li>
                    <li OnClick="Trigger(this,'gm-STATION7')">Crosby & Nash Radio</li>
                    <li OnClick="Trigger(this,'gm-STATION8')">Lounge Instrumentals</li>
            -->
        </ul>
        <button OnClick="Trigger(this,'gm-PAUSE')" class="tw-btn tw-yel">
            Pause
        </button>
        <button OnClick="Trigger(this,'gm-NEXT')" class="tw-btn tw-grn">Skip
        </button>
        <button OnClick="Trigger(this,'gm-STOP')" class="tw-btn tw-red">Stop
        </button>
    </div>
</div>

<div class="page" id="mp3">
    <div class="content">
        <h3>NUC MP3 Music Controls</h3>
        <iframe src='musicbee/index.html' frameborder='0' scrolling="yes"
                width='500' height='600'></iframe>
    </div>
</div>

<div class="footer" style="clear:left">
    <h2>Wysocki Home Control System</h2>
</div>

</body>
</html>


because this function gets run each and every time the document is ready it then creates a new websocket connection and does not close the old one gracefully.

you need to set the connection into a persistent variable in your browser and check for it's existence. and if it is not there then make the connection. or you need to create a function to close the websocket each time you naviagte away from the page which you should have in there as well.
If you like the work I have been doing then feel free to Image

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

Re: Webserver

Post by kgschlosser » Wed Mar 06, 2019 5:41 pm

also sorry about the reformatting of your original code. my IDE does it automatically to make it easier to read.
If you like the work I have been doing then feel free to Image

wysocki
Experienced User
Posts: 56
Joined: Mon Nov 23, 2015 9:23 pm
Location: Los Angeles area

Re: Webserver

Post by wysocki » Wed Mar 06, 2019 6:45 pm

Thanks for looking at this. Actually I like your reformatting - what IDE are you using? Anyway, there still are errors in the log with your version. Here's what I get when I reload the html page:

Code: Select all

2019-03-06 10:40:16  NOTICE: Websocket closing: GOING_AWAY
2019-03-06 10:40:16  NOTICE: Websocket closing: GOING_AWAY
2019-03-06 10:40:16  EVENT: HTTP.WsClientDisconnected [('192.168.1.101', 56736)]
2019-03-06 10:40:16  EVENT: HTTP.WsClientDisconnected [('192.168.1.101', 56737)]
2019-03-06 10:40:16  ERROR: Webserver error /musicbee/css/jquery.alerts.css
2019-03-06 10:40:16  ERROR: Exception [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-06 10:40:16  ERROR: Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-06 10:40:16  INFO: ----------------------------------------
2019-03-06 10:40:16  INFO: Exception happened during processing of request from ('::ffff:192.168.1.101', 56757, 0, 0)
2019-03-06 10:40:16  ERROR: Traceback (most recent call last):
2019-03-06 10:40:16  ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-06 10:40:16  ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-06 10:40:16  ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-06 10:40:16  ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-06 10:40:16  ERROR: File "socket.pyc", line 283, in close
2019-03-06 10:40:16  ERROR: File "socket.pyc", line 307, in flush
2019-03-06 10:40:16  ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-06 10:40:16  INFO: ----------------------------------------
2019-03-06 10:40:16  EVENT: HTTP.WsClientConnected [('192.168.1.101', 56761)]
Then I commented out the iframe for the musicbee code and the errors went away!!! Here's the musicbee index.html code:

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-1.10.2.min.js"></script>-->
<script src="js/jquery-2.0.3.min.js"  type="text/javascript"></script>
<script src="js/script.js"></script>
<!--<script src="js/jquery-1.10.2.min.js" type="text/javascript"></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 data-fn = "update" style="position: absolute; top: 3px; right: 5px; cursor: pointer;"> <img src = "./images/buttons/mbIconFalse.png" style= "width: 48px; height: 48px;" id = "mbIcon" alt=""> </div>
<div data-fn = "confirm"  id = "exit" style="position: absolute; top: 64px; right: 5px;"> <img id = "exitIcon" 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>
<!--<button  data-action="MB.repeat"> <img  class = "imgButton" id = "repeat" alt=""> </button>
    <button  data-action="MB.shuffle"> <img  class = "imgButton" id = "shuffle" alt=""> </button>
    <button  data-action="MB.sound.mute"> <img  class = "imgButton" id = "mute" alt=""> </button>
	<button  data-action="SYS.sound.mute"> <img  class = "imgButton" id = "sysMute" alt=""> </button>
    <button  data-action="MB.stopAfter"> <img  class = "imgButton" id = "stopAfter" alt=""> </button> -->
</div>
<div class = "field" id="info" style="float:left">&nbsp; </div>
    <br/>
<!--
    <input style = "margin: 3px 6px 0px 3px" type="range" class = "progress" id="progress" value="0" min="0" max="1000"/>
    <div class="smartSliderT">&nbsp;</div>
    <div class="smartSliderL">
      <button  data-action="MB.sound.voldown"> <img src = "./images/buttons/Minus.png"  class = "plusMinus" alt=""> </button>
    </div>
    <div class="smartSlider">
      <input type="range" class = "mb" id="VolumeLevelChanged" value="0" min="0" max="100"/>
    </div>
    <div class="smartSliderR">
      <button  data-action="MB.sound.volup"> <img src = "./images/buttons/Plus.png"  class = "plusMinus" alt=""> </button>
    </div>
    <div class="smartSliderB">&nbsp;</div>
    <div class="smartSliderL">
      <button  data-action="SYS.sound.voldown"> <img src = "./images/buttons/Minus.png"  class = "plusMinus" alt=""> </button>
    </div>
    <div class="smartSlider">
      <input type="range" class = "system" id="Volume" value="0" min="0" max="100"/>
    </div>
    <div class="smartSliderR">
      <button  data-action="SYS.sound.volup"> <img src = "./images/buttons/Plus.png"  class = "plusMinus" alt=""> </button>
    </div>
-->	
    <div class="smartSliderB">&nbsp;</div>
    <div class="select-styled">
      <select id="playlists">
      </select>
    </div>
    <div class="select-styled">
      <select id="tracks">
      </select>
    </div>
	
<!--	
    <div class="select-styled">
      <select id="stars">
      </select>
    </div>
    <div class="select-styled">
      <select id="sendtoplst">
      </select>
    </div>
-->
  </div>
</div>
<!--
<div class = "timeStr"  id="timeStr";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
-->
</body>
</html>
EDIT!!!!
Ahh, just now the log threw up some more error messages, even with the musicbee code commented out. Here's the log:

Code: Select all

2019-03-06 11:19:43  ERROR: Webserver error /scripts/jquery-2.1.4.min.js
2019-03-06 11:19:43  ERROR: Exception [Errno 10054] An existing connection was forcibly closed by the remote host
2019-03-06 11:19:43  ERROR: Webserver: Exception on handle_one_request: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-06 11:19:43  INFO: ----------------------------------------
2019-03-06 11:19:43  INFO: Exception happened during processing of request from ('::ffff:192.168.1.101', 58166, 0, 0)
2019-03-06 11:19:43  ERROR: Traceback (most recent call last):
2019-03-06 11:19:43  ERROR: File "SocketServer.pyc", line 596, in process_request_thread
2019-03-06 11:19:43  ERROR: File "SocketServer.pyc", line 331, in finish_request
2019-03-06 11:19:43  ERROR: File "SocketServer.pyc", line 654, in __init__
2019-03-06 11:19:43  ERROR: File "SocketServer.pyc", line 713, in finish
2019-03-06 11:19:43  ERROR: File "socket.pyc", line 283, in close
2019-03-06 11:19:43  ERROR: File "socket.pyc", line 307, in flush
2019-03-06 11:19:43  ERROR: error: [Errno 10053] An established connection was aborted by the software in your host machine
2019-03-06 11:19:43  INFO: ----------------------------------------
2019-03-06 11:19:44  EVENT: HTTP.WsClientConnected [('192.168.1.101', 58167)]

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

Re: Webserver

Post by kgschlosser » Thu Mar 07, 2019 6:47 am

WebStorm is the IDE I do not know if they have a free edition of it. I have all of the commercial JetBrains IDE's. I know that there is a free version of PyCharm and it will do HTML as well. not as in depth as WebStorm, but it will work.

I have been going over the code some. and this is what I have come up with. This is kind of a test. so it is probably not going to work. There is still some formatting issues that need to be addressed.

what I would do is use the inspector in your browser to see what is going on.
I believe you have some kind of an error in

"/musicbee/css/jquery.alerts.css"

and this is causing the websocket to get closed in a not so nice manner. and that is causing the second error

"An established connection was aborted by the software in your host machine"

if you can send me the whole website that you have made up including all of the style sheets I will have a look and see what is happening.
And if you want I can organize everything up so it is easier to understand what is going on.
Attachments
ha_control.zip
(5.46 KiB) Downloaded 9 times
If you like the work I have been doing then feel free to Image

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

Re: Webserver

Post by kgschlosser » Thu Mar 07, 2019 6:52 am

and I did want to mention the dynamic nature of using javascript. You are not going to need to use an iframe at all. and all of the html code for the musicbee as well as your "playlist" can be stored directly in EG and passed over the websocket and then we can use javascript to dynamically create the page elements. this is going to make for a setup that will change as you expand your music library. just have to add some page up and down buttons for the playlist.
If you like the work I have been doing then feel free to Image

therealbiglou
Experienced User
Posts: 123
Joined: Sat May 19, 2012 4:33 am

Re: Webserver

Post by therealbiglou » Thu Mar 28, 2019 2:47 am

Is there a way to make it so that an html file changes automatically without page refresh based on an EG event?

For instance, I control multiple things on my HTPC with EG including cable TV, streaming, etc. I currently have separate HTML files for each service that includes a remote interface for just that. The problem is, this can get out of sync with what's actually going on with EG.

I'm hoping to have a single web remote that dynamically displays only the relevant remote buttons based on the current events in EG without the user needing to refresh the page. I've got sending commands from the webpage to EG without refresh thanks to AJAX, but I want the reverse to happen as well.

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

Re: Webserver

Post by kgschlosser » Thu Mar 28, 2019 7:17 am

best way to go about that is using dynamic content by means of javascript and a websocket connection.
This way if something in EG does change it will update the webpage.

so you would send over the websocket a command that should generate an event. and based on that event you are able to pass back over the websocket a json object that contains all of the information that is needed to build the page

if you have page layouts that are very similar in design button locations things of that nature you can show and hide elements and change the text that is being displayed on button and other elements. you can essentially change anything about the element you want.
if you do this you will end up with a single webpage where the whole layout is defined in an html file and you alter that page as needed

If you have radically different layouts then it might be easier to store the html code for each of the different pages as a string and set markers in the string that you can replace with the data you want in there and then set the string as the page code.
just like above you will end up with a single webpage except the body element is going to be completely blank. in another file where you house the javascript code this is where the webpages will be but as strings of text. once you alter the string to suit your needs you can set it to the body element.


and when you say without page refresh do you mean without refresh having to be done manually by the user? or not at all? either way can be done. you can have the program force refresh the page if anything changes or you can leave it up to the user to do themselves.
If you like the work I have been doing then feel free to Image

therealbiglou
Experienced User
Posts: 123
Joined: Sat May 19, 2012 4:33 am

Re: Webserver

Post by therealbiglou » Fri Mar 29, 2019 2:17 pm

Thanks for the tip! While I'm pretty comfortable with HTML, I'm only slightly familiar with JS and have no experience with Websockets. Do you know how to get the initial connection with EG working? And how do I pass events to the webpage?

I think what I could do is contain each remote interface into its own DIV and show/hide each DIV through JS. So, if EG sends an event like webserver.remote.cable, it would hide all DIVs without the ID of #cable and only show #cable. Does this sound feasible?

User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Webserver

Post by yokel22 » Fri Mar 29, 2019 8:12 pm

Examples of every thing kg is talking about can be found in this demo. viewtopic.php?f=13&t=9487

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

Re: Webserver

Post by kgschlosser » Fri Mar 29, 2019 8:27 pm

heyyy thanks yokel I had forgotten about that.
If you like the work I have been doing then feel free to Image

therealbiglou
Experienced User
Posts: 123
Joined: Sat May 19, 2012 4:33 am

Re: Webserver

Post by therealbiglou » Fri Mar 29, 2019 9:41 pm

Wow! Thanks! That's a huge help to get me started!!!

By the way guys, I recommend a website called https://gonative.io/. It lets you create a native mobile app from a website. I set up a DDNS and pointed gonative.io to my ddns-server-url:port# of my remote, and now I have an app on my phone/tablets that gets me directly to my remote. Aside from adding native menus and whatnot, another great feature is that you can tap on buttons rapidly (for example, volume buttons) and the webview won't zoom in like it does on mobile browsers.

It costs to publish your app in the app stores, but it's free if you deploy it locally.

Post Reply