Skip to content

Commit fb4e9dc

Browse files
committed
fixing a crash when server is down
1 parent b6c0132 commit fb4e9dc

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

pyradio/radio.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5599,24 +5599,25 @@ def _show_remote_control_server_not_active(self):
55995599
self._remote_control_window.show(self.outerBodyWin)
56005600

56015601
def _show_remote_control_server_active(self):
5602-
txt = '''
5603-
|PyRadio Remote Control Server| is active!
5602+
if self._remote_control_server is not None:
5603+
txt = '''
5604+
|PyRadio Remote Control Server| is active!
56045605
5605-
||Text Address: |http://{0}
5606-
||_Web Address: |http://{0}/html
5606+
||Text Address: |http://{0}
5607+
||_Web Address: |http://{0}/html
56075608
5608-
||Press "|s|" to stop the server, or'''.format(
5609-
self._remote_control_server.ip + \
5610-
'|:|' + str(
5611-
self._cnf.active_remote_control_server_port
5609+
||Press "|s|" to stop the server, or'''.format(
5610+
self._remote_control_server.ip + \
5611+
'|:|' + str(
5612+
self._cnf.active_remote_control_server_port
5613+
)
5614+
)
5615+
self._show_help(
5616+
txt,
5617+
self.ws.REMOTE_CONTROL_SERVER_ACTIVE_MODE,
5618+
caption=' Remote Control Enabled ',
5619+
is_message=True
56125620
)
5613-
)
5614-
self._show_help(
5615-
txt,
5616-
self.ws.REMOTE_CONTROL_SERVER_ACTIVE_MODE,
5617-
caption=' Remote Control Enabled ',
5618-
is_message=True
5619-
)
56205621

56215622
def keypress(self, char):
56225623
if self._system_asked_to_terminate:

pyradio/server.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ def send_song_title(self, msg=None):
965965
Content-Type: text/event-stream
966966
Cache-Control: no-cache
967967
Connection: keep-alive, Keep-Alive
968-
Keep-Alive: timeout=9000, max=1000
968+
Keep-Alive: timeout=1, max=1000
969969
Content-Length: {}
970970
971971
'''.format(len(b_msg))
@@ -975,7 +975,7 @@ def send_song_title(self, msg=None):
975975
Content-Type: text/event-stream; charset=UTF-8
976976
Cache-Control: no-cache
977977
Connection: keep-alive, Keep-Alive
978-
Keep-Alive: timeout=9000, max=1000
978+
Keep-Alive: timeout=1, max=1000
979979
Content-Length: {}
980980
981981
'''.format(len(b_msg)).encode('utf-8')
@@ -995,7 +995,7 @@ def _send_raw(self, msg):
995995
txt = '''HTTP/1.1 200 OK
996996
Content-Type: text/txt; charset=utf-8
997997
Connection: keep-alive, Keep-Alive
998-
Keep-Alive: timeout=9000, max=1000
998+
Keep-Alive: timeout=1, max=1000
999999
Content-Length: {}
10001000
10011001
'''.format(len(b_msg))
@@ -1004,7 +1004,7 @@ def _send_raw(self, msg):
10041004
txt = '''HTTP/1.1 200 OK
10051005
Content-Type: text/txt; charset=UTF-8
10061006
Connection: keep-alive, Keep-Alive
1007-
Keep-Alive: timeout=9000, max=1000
1007+
Keep-Alive: timeout=1, max=1000
10081008
Content-Length: {}
10091009
10101010
'''.format(len(b_msg)).encode('utf-8')
@@ -1031,7 +1031,7 @@ def _send_text(self,
10311031
txt = '''HTTP/1.1 200 OK
10321032
Content-Type: text/txt; charset=UTF-8
10331033
Connection: keep-alive, Keep-Alive
1034-
Keep-Alive: timeout=9000, max=1000
1034+
Keep-Alive: timeout=1, max=1000
10351035
Content-Length: {}
10361036
10371037
'''.format(len(b_msg))
@@ -1040,7 +1040,7 @@ def _send_text(self,
10401040
txt = '''HTTP/1.1 200 OK
10411041
Content-Type: text/txt; charset=UTF-8
10421042
Connection: keep-alive, Keep-Alive
1043-
Keep-Alive: timeout=9000, max=1000
1043+
Keep-Alive: timeout=1, max=1000
10441044
Content-Length: {}
10451045
10461046
'''.format(len(b_msg)).encode('utf-8')
@@ -1060,7 +1060,7 @@ def _send_html(self, msg=None, put_script=False):
10601060
txt = '''HTTP/1.1 200 OK
10611061
Content-Type: text/html; charset=UTF-8
10621062
Connection: keep-alive, Keep-Alive
1063-
Keep-Alive: timeout=9000, max=1000
1063+
Keep-Alive: timeout=1, max=1000
10641064
Content-Length: {}
10651065
10661066
'''.format(len(b_msg))
@@ -1069,7 +1069,7 @@ def _send_html(self, msg=None, put_script=False):
10691069
txt = '''HTTP/1.1 200 OK
10701070
Content-Type: text/html; charset=UTF-8
10711071
Connection: keep-alive, Keep-Alive
1072-
Keep-Alive: timeout=9000, max=1000
1072+
Keep-Alive: timeout=1, max=1000
10731073
Content-Length: {}
10741074
10751075
'''.format(len(b_msg)).encode('utf-8')

0 commit comments

Comments
 (0)