Ticket #9599 (closed defect: fixed)
Opened 17 months ago
Last modified 7 weeks ago
User friendly error message when port is busy
| Reported by: | anatoly techtonik <techtonik@…> | Owned by: | thijstriemstra |
|---|---|---|---|
| Priority: | high | Milestone: | 0.13 |
| Component: | web frontend/tracd | Version: | 0.12dev |
| Severity: | normal | Keywords: | bitesized, patch |
| Cc: | thijstriemstra | ||
| Release Notes: |
tracd: Report failure to listen on a socket |
||
| API 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
Change History
comment:1 Changed 17 months ago by rblank
- Keywords bitesized added
- Milestone set to unscheduled
comment:2 Changed 16 months ago by Thijs Triemstra <lists@…>
- Cc lists@… 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 Changed 16 months ago by rblank
- Keywords bitesized, patch added; bitesized removed
- Milestone changed from unscheduled to 0.13
- Owner set to rblank
- Priority changed from normal to high
comment:4 Changed 15 months ago by rblank
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 Changed 15 months ago by rblank
- Resolution set to fixed
- Status changed from new to 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 Changed 15 months ago by rblank
- Owner changed from rblank to anatoly techtonik <techtonik@…>
comment:7 Changed 15 months ago by Thijs Triemstra <lists@…>
- Owner changed from anatoly techtonik <techtonik@…> to Thijs Triemstra <lists@…>
Sorry but I just noticed my patch was applied so changing the owner if that's ok.
comment:8 Changed 15 months ago by rblank
Oops, yes, sorry for the confusion.
comment:9 Changed 14 months ago by thijstriemstra
- Cc thijstriemstra added; lists@… removed
- Owner changed from Thijs Triemstra <lists@…> to thijstriemstra
comment:10 Changed 7 weeks ago by Alex Willmer <al.willmer@…>
- Release Notes modified (diff)
comment:11 Changed 7 weeks ago by anatoly techtonik <techtonik@…>
I still get credits in the SVN log. :P



I wouldn't go as far as connecting and seeing what's running there, but a better error message would be nice indeed.