Using Flask API and WSGIServer, I'm able to launch it over HTTPS. But, I want our API as a windows service. So, when I run windows service and hit "https://127.0.0.1:88", I'm getting "Error: Client network socket disconnected before secure TLS connection was established". Any advice on how to fix or debug.
See code snippets below.
import sys
import servicemanager
import win32serviceutil
from gevent import pywsgi
#Flask App
from myapp import app
class Service(win32serviceutil.ServiceFramework):
_svc_name_ = "MyService"
_svc_display_name_ = "MyServer"
_svc_description_ = "MyAPI"
def __init__(self, *args):
super().__init__(*args)
self.http_server = pywsgi.WSGIServer(('127.0.0.1', 88), app, keyfile='privateKey.key', certfile='certificate.crt')
self.SvcStop = self.http_server.stop
self.SvcDoRun = self.http_server.serve_forever
if __name__ == '__main__':
if len(sys.argv) == 1:
servicemanager.Initialize()
servicemanager.PrepareToHostSingle(Service)
servicemanager.StartServiceCtrlDispatcher()
else:
win32serviceutil.HandleCommandLine(Service)