Open dcimike125 opened 3 years ago
Your post inspired me to make an account because I just ran into the same exact thing. I was messing around with this early this morning, and it worked fine, circa 3am EST. Tried it tonight when I got home and got that error.
Initiating Locast2Plex v0.6.2
Opening and Verifying Configuration File.
/home/pi/Downloads/locast2plex-0.6.3/config/config.ini
/home/pi/Downloads/locast2plex-0.6.3/config.ini
Loading Configuration File: /home/pi/Downloads/locast2plex-0.6.3/config.ini
Tuner count set to 3
Server is set to run on 0.0.0.0:6077
No UUID found. Generating one now...
UUID set to: twkmzxqo...
Getting user location...
Getting location via IP Address.
Got external IP XX.XXX.XXX.XXX.
Got location as Philadelphia - DMA 504 - Lat\Lon 39.9523-75.1638
Logging into Locast using username tXXX@gXXX.com...
Validating User Info...
User Info obtained.
User didDonate: True
User donationExpire: 2021-03-20 04:49:04
Starting First time Stations refresh...
Checking FCC facilities database for updates.
Traceback (most recent call last):
File "main.py", line 67, in
I wouldn't say I'm dumber than a box of rocks, but I'm definitely learning all this on the fly.
in the lib/stations.py file Change the facility_url from http:// to https://
facility_url = 'https://transition.fcc.gov/ftp/Bureaus/MB/Databases/cdbs/facility.zip'
Thomas, I made the change and now get this error: Starting First time Stations refresh... Checking FCC facilities database for updates. Traceback (most recent call last): File "/usr/lib/python3.7/urllib/request.py", line 1324, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/usr/lib/python3.7/http/client.py", line 1244, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1290, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1239, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output self.send(msg) File "/usr/lib/python3.7/http/client.py", line 966, in send self.connect() File "/usr/lib/python3.7/http/client.py", line 1407, in connect server_hostname=server_hostname) File "/usr/lib/python3.7/ssl.py", line 412, in wrap_socket session=session File "/usr/lib/python3.7/ssl.py", line 853, in _create self.do_handshake() File "/usr/lib/python3.7/ssl.py", line 1117, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:1056)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 67, in
Thanks for that tip Thomas, but same boat with the DH_KEY error, to the letter.
Doing a little research, I'm feeling that this second error might be python related but I could (probably) be wrong
Got the same issue. thought is was on my end.... I'm running unraid and have the same issue but can't even edit that file. Seems my docker instance on unraid isn't configurable afaik.
Same problem here - knew I should have checked for trouble threads before updating my install.
File "/usr/local/lib/python3.8/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer
Initiating Locast2Plex v0.6.2
Opening and Verifying Configuration File.
/app/config/config.ini
Loading Configuration File: /app/config/config.ini
Tuner count set to 3
Server is set to run on 192.168.1.4:6077:6077
UUID set to: yipjukop...
Getting user location...
Getting location via IP Address.
Got external IP OBFUSCATED BY ME
Got location as Los Angeles - DMA 803 - Lat\Lon 33.7706-118.182
Logging into Locast using username MY EMAIL...
Validating User Info...
User Info obtained.
User didDonate: True
User donationExpire: 2021-03-17 16:05:00
Starting First time Stations refresh...
Checking FCC facilities database for updates.
Traceback (most recent call last):
File "/app/main.py", line 67, in
File "/usr/local/lib/python3.8/http/client.py", line 268, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/local/lib/python3.8/socket.py", line 669, in readinto return self._sock.recv_into(b) ConnectionResetError: [Errno 104] Connection reset by peer
On my end, adding Thomas's modification fixes the issue, but I wonder if that's because I'm using Windows. I see a fix for this that I'll look into implementing from code.
I'm on Ubuntu 20.04 and had the same ssl error that @dcimike125 after the http to https change. Turns out for me it was a problem with the openssl config on Ubuntu. This fixed it for me https://askubuntu.com/questions/1233186/ubuntu-20-04-how-to-set-lower-ssl-security-level
Thomas's Mod that was added the latest package resolved it for me. thanks guys!
@condodog: I would be careful about changing that for your entire server, as I think it presents a security risk. The change below only downgrades it for the connection to the fcc server
@dcimike125: Could you add/modify the following, and let me know if that fixes the issue (note, line numbers are following changes made):
stations.py
, line 2, add a line below:
import ssl
stations.py
, line 14, add the following two lines:
fcc_ssl_context= ssl.SSLContext()
fcc_ssl_context.set_ciphers('HIGH:!DH:!aNULL')
stations.py
, line 46, modify the following line to read:
resp = urllib.request.urlopen(url_head, context=fcc_ssl_context)
stations.py
, line 163, modify/add the following lines to read:
with urllib.request.urlopen(facility_url, context=fcc_ssl_context) as fcc_facility_net:
fcc_facility_data = fcc_facility_net.read()
with open(facility_zip_dl_path, 'wb') as fcc_facility_file:
fcc_facility_file.write(fcc_facility_data)
@tgorgdotcom That worked for me!! Took some doing to get the indentations right, but once I did it came right up!
It didn't work for me - either thr cast on my hand or fatigue most likely the culprit. adding openssl_conf = default_conf & changinf CipherString = DEFAULT:@SECLEVEL=2 to 1 did though if only as a temp solution.
I do appreciate everyone's input thoiugh
Saw this issue this morning. Updated to the latest git hash and re-built the container and things are back up and running again for me. Excellent work guys!
@ten17eighty1 That worked for me!! Took some doing to get the indentations right, but once I did it came right up! this box'oRocks is interested in the proper indentations you used...
Looks like that did not do the trick, after all -- it worked fine that evening, but again subsequently not so much.
Here's my stations from line 1 to 77
import time import urllib import ssl import zipfile import os import datetime import json import pathlib
from lib.l2p_tools import clean_exit from lib.filelock import Timeout, FileLock from lib.dma_markets import get_dma_info
fcc_ssl_context= ssl.SSLContext() fcc_ssl_context.set_ciphers('HIGH: !DH: !aNULL')
def stations_process(config, locast, location): try: while True: time.sleep(config["main"]["fcc_delay"])
# Work in eastern time, since that is what the FCC is using to determine maintenance times
currentTime = datetime.datetime.now(tz=EST5EDT())
# if we find we're returning from delay at a time that the FCC is doing maintenance, sleep a bit more...
if (currentTime.hour >= 3) and (currentTime.hour <= 5):
# get the exact time we need to wait until we can grab the FCC data
sleepTime = ((6 - currentTime.hour) * 60 * 60)
sleepTime = (sleepTime - (currentTime.minute + 60))
sleepTime = (sleepTime - currentTime.second)
time.sleep(sleepTime)
refresh_dma_stations_and_channels(config, locast, location)
except KeyboardInterrupt:
clean_exit()
def refresh_dma_stations_and_channels(config, locast, location): fcc_stations = get_fcc_stations(config) generate_dma_stations_and_channels_file(config, locast, location, fcc_stations)
def get_online_file_time(facility_url): url_head = urllib.request.Request(facility_url, method='HEAD') resp = urllib.request.urlopen(url_head, context=fcc_ssl_context) online_file_time = resp.headers['last-modified'].replace(" GMT", "") online_file_time = datetime.datetime.strptime(online_file_time, '%a, %d %b %Y %H:%M:%S') online_file_time = online_file_time.replace(tzinfo=EST5EDT()).astimezone(datetime.timezone.utc) return online_file_time
def get_offline_file_time(facility_zip_dl_path): offline_file_time = datetime.datetime.utcfromtimestamp(os.path.getmtime(facility_zip_dl_path)) offline_file_time = offline_file_time.replace(tzinfo=datetime.timezone.utc) return offline_file_time
def fcc_db_format(fac_line): current_date = datetime.datetime.utcnow()
clean_line = fac_line.strip()
fac_line_split = clean_line.split('|')
fac_template = {
"comm_city": "",
"comm_state": "",
"eeo_rpt_ind": "",
"fac_address1": "",
"fac_address2": "",
"fac_callsign": "",
"fac_channel": "",
"fac_city": "",
"fac_country": "",
"fac_frequency": "",
"fac_service": "",
"fac_state": "",
"fac_status_date": "",
"fac_type": "",
"facility_id": "",
"lic_expiration_date": "",
"fac_status": "",
"fac_zip1": "",
"fac_zip2": "",
"station_type": "",
"assoc_facility_id": "",
"callsign_eff_date": "",
"tsid_ntsc": "",
"tsid_dtv": "",
"digital_status": "",
"sat_tv": "",
"network_affil": "",
"nielsen_dma": "",
"tv_virtual_channel": "",
"last_change_date": "",
"end_of_record": "",
}
formatteddict = {}
key_num = 0
for fcc_key in list(fac_template.keys()):
insert_value = None
if fac_line_split[key_num] != '':
insert_value = fac_line_split[key_num]
formatteddict[fcc_key] = insert_value
key_num += 1
# Check if expired
if (not formatteddict['fac_status'] or formatteddict['fac_status'] != 'LICEN'
or not formatteddict['lic_expiration_date']):
return None
fac_lic_expiration_date_split = formatteddict["lic_expiration_date"].split('/')
fac_lic_expiration_date_datetime = datetime.datetime(int(fac_lic_expiration_date_split[2]),
int(fac_lic_expiration_date_split[0]),
int(fac_lic_expiration_date_split[1]),
23, 59, 59, 999999)
if fac_lic_expiration_date_datetime < current_date:
return None
# Check if we have a correct signal type
if formatteddict['fac_service'] not in ['DT', 'TX', 'TV', 'TB', 'LD', 'DC']:
return None
return formatteddict
def get_fcc_stations(config):
fcc_cache_dir = pathlib.Path(config["main"]["cache_dir"]).joinpath("stations")
facility_url = 'https://transition.fcc.gov/ftp/Bureaus/MB/Databases/cdbs/facility.zip'
facility_zip_dl_path = pathlib.Path(fcc_cache_dir).joinpath("facility.zip")
fcc_unzipped_dat = pathlib.Path(fcc_cache_dir).joinpath("facility.dat")
fcc_cached_file = pathlib.Path(fcc_cache_dir).joinpath("tv_facilities.json")
fcc_cached_file_lock = pathlib.Path(fcc_cache_dir).joinpath("tv_facilities.json.lock")
why_download = None
if not os.path.exists(facility_zip_dl_path):
why_download = "FCC facilities database cache missing."
else:
print("Checking FCC facilities database for updates.")
offline_file_time = get_offline_file_time(facility_zip_dl_path)
online_file_time = get_online_file_time(facility_url)
if not offline_file_time <= online_file_time:
print("Cached facilities database is current.")
else:
why_download = "Online facilities database is newer."
if why_download:
print(why_download + ' Downloading the latest FCC facilities database...')
# remove old copies of zip and dat
if os.path.exists(facility_zip_dl_path):
os.remove(facility_zip_dl_path)
if os.path.exists(fcc_unzipped_dat):
os.remove(fcc_unzipped_dat)
if (not os.path.exists(facility_zip_dl_path)):
urllib.request.urlretrieve(facility_url, facility_zip_dl_path)
if (not os.path.exists(fcc_unzipped_dat)) and (os.path.exists(facility_zip_dl_path)):
print('Unzipping FCC facilities database...')
with urllib.request.urlopen(facility_url, context=fcc_ssl_context) as fcc_facility_net:
fcc_facility_data = fcc_facility_net.read()
with open (facility_zip_dl_path, 'wb') as fcc_facility_file:
fcc_facility_file.write(fcc_facility_data)
with zipfile.ZipFile(facility_zip_dl_path, 'r') as zip_ref:
zip_ref.extractall(fcc_cache_dir)
And here's the result
Initiating Locast2Plex v0.6.4 Opening and Verifying Configuration File. /home/pi/locast2plex-0.6.4/config/config.ini /home/pi/locast2plex-0.6.4/config.ini Loading Configuration File: /home/pi/locast2plex-0.6.4/config.ini Tuner count set to 3 Server is set to run on X.X.X.X:6077 UUID set to: twkmzxqo... Getting user location... Getting location via IP Address. Got external IP X.X.X.X. Got location as Philadelphia - DMA 504 - Lat\Lon 39.9523-75.1638 Logging into Locast using username e@mail.com... Validating User Info... User Info obtained. User didDonate: True User donationExpire: 2021-03-20 04:49:04 Starting First time Stations refresh... FCC facilities database cache missing. Downloading the latest FCC facilities database... Traceback (most recent call last): File "/usr/lib/python3.7/urllib/request.py", line 1324, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/usr/lib/python3.7/http/client.py", line 1244, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1290, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1239, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output self.send(msg) File "/usr/lib/python3.7/http/client.py", line 966, in send self.connect() File "/usr/lib/python3.7/http/client.py", line 1407, in connect server_hostname=server_hostname) File "/usr/lib/python3.7/ssl.py", line 412, in wrap_socket session=session File "/usr/lib/python3.7/ssl.py", line 853, in _create self.do_handshake() File "/usr/lib/python3.7/ssl.py", line 1117, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:1056)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 67, in
No, it didn't work for me. I reverted back to @condodog's suggestion
Same issues for me. urllib.error.URLError: <urlopen error [SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:1123)>
Was on 0.6.2 and I upgraded to 0.6.4... had 'spaces/tabs errors' trying to follow @tgorgdotcom instructions to @dcimike125 above..(I just copied/pasted - and have no clue about spaces/tabs). Reverted back, and tried to mess with the config.ini to lower the ssl (as per @condodog 's link above)...still no success. I'm stuck. Running Ubuntu 20.04.
I also didn't have luck with @tgorgdotcom suggestion from the Ubuntu page. It seems to imply that process would change the SSL only for locast2plex if executed correctly, but it didn't work as prescribed. And again, I'm also a whole noob.
For the moment, my workaround has been to make a copy of openssl.cnf and rename it to somthing else, say openssl123.cnf, and then change the last line in the renamed copy
CipherString = DEFAULT:@SECLEVEL=1
Then run the line below in terminal
export OPENSSL_CONF=/path/to/my/openssl123.cnf
(changing '/path/to/my' to the actual path)
Which (I think) is a variation on what the Ubuntu post was suggesting. But 'm imagining doing it this way is affecting the entire system and not just locast2plex. That said, I'm able to run it after doing this.
I just installed locast2plex on my raspberry pi4. when I run the main.py, I get a ConnectionResetError: [Errno 104] Connection reset by peer error.
pi@raspberrypi:/locast2plex-main $ sudo python3 main.py Initiating Locast2Plex v0.6.2 Opening and Verifying Configuration File. /home/pi/locast2plex-main/config/config.ini /home/pi/locast2plex-main/config.ini Loading Configuration File: /home/pi/locast2plex-main/config.ini Tuner count set to 3 Server is set to run on 192.168.1.12:6077 UUID set to: usunumou... Getting user location... Getting location via IP Address. Got external IP 68...35. Got location as New York - DMA 501 - Lat\Lon .13367-.406876 Logging into Locast using username mike**@gmail.com... Validating User Info... User Info obtained. User didDonate: True User donationExpire: 2021-02-11 20:00:01 Starting First time Stations refresh... Checking FCC facilities database for updates. Traceback (most recent call last): File "main.py", line 67, in stations.refresh_dma_stations_and_channels(config, locast, location_info.location) File "/home/pi/locast2plex-main/lib/stations.py", line 38, in refresh_dma_stations_and_channels fcc_stations = get_fcc_stations(config) File "/home/pi/locast2plex-main/lib/stations.py", line 144, in get_fcc_stations online_file_time = get_online_file_time(facility_url) File "/home/pi/locast2plex-main/lib/stations.py", line 44, in get_online_file_time resp = urllib.request.urlopen(url_head) File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python3.7/urllib/request.py", line 525, in open response = self._open(req, data) File "/usr/lib/python3.7/urllib/request.py", line 543, in _open '_open', req) File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain result = func(args) File "/usr/lib/python3.7/urllib/request.py", line 1352, in http_open return self.do_open(http.client.HTTPConnection, req) File "/usr/lib/python3.7/urllib/request.py", line 1327, in do_open r = h.getresponse() File "/usr/lib/python3.7/http/client.py", line 1336, in getresponse response.begin() File "/usr/lib/python3.7/http/client.py", line 306, in begin version, status, reason = self._read_status() File "/usr/lib/python3.7/http/client.py", line 267, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/lib/python3.7/socket.py", line 589, in readinto return self._sock.recv_into(b) ConnectionResetError: [Errno 104] Connection reset by peer pi@raspberrypi:/locast2plex-main $
Please help as I'm dumber than a box of rocks