Edgewall Software
Modify

Opened 14 years ago

Closed 13 years ago

Last modified 12 years ago

#9599 closed defect (fixed)

User friendly error message when port is busy

Reported by: anatoly techtonik <techtonik@…> 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 Remy Blank, 14 years ago

Keywords: bitesized added
Milestone: unscheduled

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

comment:2 by Thijs Triemstra <lists@…>, 14 years ago

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

     
    2222import pkg_resources
    2323import os
    2424import sys
     25import socket
    2526from SocketServer import ThreadingMixIn
    2627
    2728from trac import __version__ as VERSION
     
    241242
    242243    if options.protocol == 'http':
    243244        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()
    249245            addr, port = server_address
    250246            if not addr or addr == '0.0.0.0':
    251                 print 'Serving on 0.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' \
    252248                       % (port, port, base_path)
    253249            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
    255263            if options.http11:
    256264                print 'Using HTTP/1.1 protocol version'
    257265            httpd.serve_forever()

comment:3 by Remy Blank, 14 years ago

Keywords: patch added
Milestone: unscheduled0.13
Owner: set to Remy Blank
Priority: normalhigh

comment:4 by Remy Blank, 13 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 Remy Blank, 13 years ago

Resolution: fixed
Status: newclosed

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 Remy Blank, 13 years ago

Owner: changed from Remy Blank to anatoly techtonik <techtonik@…>

comment:7 by Thijs Triemstra <lists@…>, 13 years ago

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 by Remy Blank, 13 years ago

Oops, yes, sorry for the confusion.

comment:9 by Thijs Triemstra, 13 years ago

Cc: Thijs Triemstra added; lists@… removed
Owner: changed from Thijs Triemstra <lists@…> to Thijs Triemstra

comment:10 by Alex Willmer <al.willmer@…>, 12 years ago

Release Notes: modified (diff)

comment:11 by anatoly techtonik <techtonik@…>, 12 years ago

I still get credits in the SVN log. :P

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Thijs Triemstra.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Thijs Triemstra to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.