Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve startup error message when bind on http port fails #134

Merged

Conversation

psteniusubi
Copy link
Contributor

Fixing issue WebOfTrust/keripy#455 for keria

New startup error messages

$ keria start
Traceback (most recent call last):
  File "/home/uroot/.local/bin/keria", line 33, in <module>
    sys.exit(load_entry_point('keria', 'console_scripts', 'keria')())
  File "/home/uroot/keria/src/keria/app/cli/keria.py", line 31, in main
    raise ex
  File "/home/uroot/keria/src/keria/app/cli/keria.py", line 25, in main
    doers = args.handler(args)
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 20, in <lambda>
    parser.set_defaults(handler=lambda args: launch(args))
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 74, in launch
    runAgent(name=args.name,
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 97, in runAgent
    doers.extend(agenting.setup(name=name, base=base, bran=bran,
  File "/home/uroot/keria/src/keria/app/agenting.py", line 63, in setup
    raise RuntimeError(f"cannot create boot http server on port {bootPort}")
RuntimeError: cannot create boot http server on port 3903
$ keria start -B 33903
Traceback (most recent call last):
  File "/home/uroot/.local/bin/keria", line 33, in <module>
    sys.exit(load_entry_point('keria', 'console_scripts', 'keria')())
  File "/home/uroot/keria/src/keria/app/cli/keria.py", line 31, in main
    raise ex
  File "/home/uroot/keria/src/keria/app/cli/keria.py", line 25, in main
    doers = args.handler(args)
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 20, in <lambda>
    parser.set_defaults(handler=lambda args: launch(args))
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 74, in launch
    runAgent(name=args.name,
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 97, in runAgent
    doers.extend(agenting.setup(name=name, base=base, bran=bran,
  File "/home/uroot/keria/src/keria/app/agenting.py", line 83, in setup
    raise RuntimeError(f"cannot create admin http server on port {adminPort}")
RuntimeError: cannot create admin http server on port 3901
$ keria start -B 33903 -a 33901
Traceback (most recent call last):
  File "/home/uroot/.local/bin/keria", line 33, in <module>
    sys.exit(load_entry_point('keria', 'console_scripts', 'keria')())
  File "/home/uroot/keria/src/keria/app/cli/keria.py", line 31, in main
    raise ex
  File "/home/uroot/keria/src/keria/app/cli/keria.py", line 25, in main
    doers = args.handler(args)
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 20, in <lambda>
    parser.set_defaults(handler=lambda args: launch(args))
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 74, in launch
    runAgent(name=args.name,
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 97, in runAgent
    doers.extend(agenting.setup(name=name, base=base, bran=bran,
  File "/home/uroot/keria/src/keria/app/agenting.py", line 108, in setup
    raise RuntimeError(f"cannot create local http server on port {httpPort}")
RuntimeError: cannot create local http server on port 3902

Error message before the fix

$ keria start
The Agency is loaded and waiting for requests...
Traceback (most recent call last):
  File "/home/uroot/.local/bin/keria", line 33, in <module>
    sys.exit(load_entry_point('keria', 'console_scripts', 'keria')())
  File "/home/uroot/keria/src/keria/app/cli/keria.py", line 31, in main
    raise ex
  File "/home/uroot/keria/src/keria/app/cli/keria.py", line 25, in main
    doers = args.handler(args)
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 20, in <lambda>
    parser.set_defaults(handler=lambda args: launch(args))
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 74, in launch
    runAgent(name=args.name,
  File "/home/uroot/keria/src/keria/app/cli/commands/start.py", line 107, in runAgent
    directing.runController(doers=doers, expire=expire)
  File "/home/uroot/keripy/src/keri/app/directing.py", line 665, in runController
    doist.do(doers=doers)
  File "/home/uroot/.local/lib/python3.10/site-packages/hio/base/doing.py", line 156, in do
    self.recur()  # increments .tyme runs recur context
  File "/home/uroot/.local/lib/python3.10/site-packages/hio/base/doing.py", line 275, in recur
    tock = dog.send(self.tyme)  # yielded tock == 0.0 means re-run asap
  File "/home/uroot/.local/lib/python3.10/site-packages/hio/base/doing.py", line 568, in do
    self.done = self.recur(tyme=tyme)
  File "/home/uroot/.local/lib/python3.10/site-packages/hio/core/http/serving.py", line 1359, in recur
    self.server.service()
  File "/home/uroot/.local/lib/python3.10/site-packages/hio/core/http/serving.py", line 846, in service
    self.serviceConnects()
  File "/home/uroot/.local/lib/python3.10/site-packages/hio/core/http/serving.py", line 765, in serviceConnects
    self.servant.serviceConnects()
  File "/home/uroot/.local/lib/python3.10/site-packages/hio/core/tcp/serving.py", line 292, in serviceConnects
    self.serviceAxes()
  File "/home/uroot/.local/lib/python3.10/site-packages/hio/core/tcp/serving.py", line 269, in serviceAxes
    self.serviceAccepts()  # populate .axes
  File "/home/uroot/.local/lib/python3.10/site-packages/hio/core/tcp/serving.py", line 196, in serviceAccepts
    cs, ca = self.accept()
  File "/home/uroot/.local/lib/python3.10/site-packages/hio/core/tcp/serving.py", line 182, in accept
    cs, ca = self.ss.accept()  # virtual connection (socket, host address)
AttributeError: 'NoneType' object has no attribute 'accept'

@psteniusubi psteniusubi changed the title Fix improve accept error message Fix improve startup error message bind on http port fails Nov 22, 2023
@psteniusubi psteniusubi changed the title Fix improve startup error message bind on http port fails Improve startup error message bind on http port fails Nov 22, 2023
@psteniusubi psteniusubi changed the title Improve startup error message bind on http port fails Improve startup error message when bind on http port fails Nov 22, 2023
@pfeairheller
Copy link
Member

Can you please fix the failing tests in the PR so we can get it merged?

Copy link

codecov bot commented Nov 22, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (843759f) 91.38% compared to head (d757f40) 91.34%.

Files Patch % Lines
src/keria/app/agenting.py 50.00% 3 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           development     #134      +/-   ##
===============================================
- Coverage        91.38%   91.34%   -0.05%     
===============================================
  Files               35       35              
  Lines             5818     5825       +7     
===============================================
+ Hits              5317     5321       +4     
- Misses             501      504       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@psteniusubi
Copy link
Contributor Author

@pfeairheller - Tests are passing now

@m00sey m00sey merged commit 97c63d0 into WebOfTrust:development Nov 30, 2023
4 of 5 checks passed
@psteniusubi psteniusubi deleted the fix-improve-accept-error-message branch December 12, 2023 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants