#9599 closed defect (fixed)
User friendly error message when port is busy
Reported by: | Owned by: | Thijs Triemstra | |
---|---|---|---|
Priority: | high | Milestone: | 1.0 |
Component: | web frontend/tracd | Version: | 0.12dev |
Severity: | normal | Keywords: | bitesized, patch |
Cc: | Thijs Triemstra | Branch: | |
Release Notes: |
tracd: Report failure to listen on a socket |
||
API Changes: | |||
Internal Changes: |
Description
tracd outputs a non-friendly error message when a port it is trying to bind is busy.
Traceback (most recent call last): File "C:\~env\Python27\lib\runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "C:\~env\Python27\lib\runpy.py", line 72, in _run_code exec code in run_globals File "c:\users\user\appdata\local\temp\easy_install-iylw6e\Trac-0.12-py2.7-win32.egg.tmp\trac\web\standalone.py", line 299, in <module> File "c:\users\user\appdata\local\temp\easy_install-iylw6e\Trac-0.12-py2.7-win32.egg.tmp\trac\web\standalone.py", line 290, in main File "c:\users\user\appdata\local\temp\easy_install-iylw6e\Trac-0.12-py2.7-win32.egg.tmp\trac\web\standalone.py", line 257, in serve File "c:\users\user\appdata\local\temp\easy_install-iylw6e\Trac-0.12-py2.7-win32.egg.tmp\trac\web\standalone.py", line 109, in __init__ File "c:\users\user\appdata\local\temp\easy_install-iylw6e\Trac-0.12-py2.7-win32.egg.tmp\trac\web\wsgi.py", line 231, in __init__ File "C:\~env\Python27\lib\SocketServer.py", line 408, in __init__ self.server_bind() File "C:\~env\Python27\lib\BaseHTTPServer.py", line 108, in server_bind SocketServer.TCPServer.server_bind(self) File "C:\~env\Python27\lib\SocketServer.py", line 419, in server_bind self.socket.bind(self.server_address) File "C:\~env\Python27\lib\socket.py", line 222, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions
This can be improved to output something like Error starting Trac server on port %s.
It may even attempt to connect to detect if there is an existing service already and it is not Trac. And output something like Some application is already running on that port
.
Official reasons for the error code http://msdn.microsoft.com/en-us/library/ms740668%28VS.85%29.aspx#winsock.wsaeacces_2
Attachments (0)
Change History (11)
comment:1 by , 14 years ago
Keywords: | bitesized added |
---|---|
Milestone: | → unscheduled |
comment:2 by , 14 years ago
Cc: | added |
---|
This patch prints out the error message but also needs to stop the server, sys.exit(1) doesn't seem to work.
Error starting Trac server on 0.0.0.0:80 view at http://127.0.0.1:80/trac Permission denied
-
trac/web/standalone.py
22 22 import pkg_resources 23 23 import os 24 24 import sys 25 import socket 25 26 from SocketServer import ThreadingMixIn 26 27 27 28 from trac import __version__ as VERSION … … 241 242 242 243 if options.protocol == 'http': 243 244 def serve(): 244 httpd = TracHTTPServer(server_address, wsgi_app,245 options.env_parent_dir, args,246 use_http_11=options.http11)247 248 print 'Server starting in PID %i.' % os.getpid()249 245 addr, port = server_address 250 246 if not addr or addr == '0.0.0.0': 251 print 'Serving on0.0.0.0:%s view at http://127.0.0.1:%s/%s' \247 loc = '0.0.0.0:%s view at http://127.0.0.1:%s/%s' \ 252 248 % (port, port, base_path) 253 249 else: 254 print 'Serving on http://%s:%s/%s' % (addr, port, base_path) 250 loc = 'http://%s:%s/%s' % (addr, port, base_path) 251 252 try: 253 httpd = TracHTTPServer(server_address, wsgi_app, 254 options.env_parent_dir, args, 255 use_http_11=options.http11) 256 except socket.error, e: 257 print 'Error starting Trac server on %s' % loc 258 print e.strerror 259 sys.exit(1) 260 261 print 'Server starting in PID %i.' % os.getpid() 262 print 'Serving on %s' % loc 255 263 if options.http11: 256 264 print 'Using HTTP/1.1 protocol version' 257 265 httpd.serve_forever()
comment:3 by , 14 years ago
Keywords: | patch added |
---|---|
Milestone: | unscheduled → 0.13 |
Owner: | set to |
Priority: | normal → high |
comment:4 by , 14 years ago
Your patch works great. The reason it doesn't exit correctly is an interference with the auto-reload mechanism, if you use it (it exits fine if you don't use auto-reload). I have a fix for that.
comment:5 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Patch applied in [10316], together with a fix to the auto-reload mechanism so that it exists correctly when the server quits.
comment:6 by , 14 years ago
Owner: | changed from | to
---|
comment:7 by , 14 years ago
Owner: | changed from | to
---|
Sorry but I just noticed my patch was applied so changing the owner if that's ok.
comment:9 by , 14 years ago
Cc: | added; removed |
---|---|
Owner: | changed from | to
comment:10 by , 13 years ago
Release Notes: | modified (diff) |
---|
I wouldn't go as far as connecting and seeing what's running there, but a better error message would be nice indeed.