-
Notifications
You must be signed in to change notification settings - Fork 96
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
Connection refused when setting port to zero and inside a docker container #276
Comments
Ah, that's a new use case for me (setting port to 0) Currently the code for I'll see if I can add more intelligence to |
I like your package and find it very useful, thank you for your work.
I have some python programming experience, but am only mediocre at it. I
can help some with testing changes. There is some documentation that is
not clear to me with setting up an SSL and TLS email server, if that is
updated I would love to try it and say how it goes; assuming you are
interested in that stuff. If this works in my docker containers, I can
test stuff like that without worrying about my development environment.
It has been a while since I looked at this. I may repeat a bit of what
was in the log item. I will also try to give you my full use case, so
you get my idea (good or bad) of how I think your software can be used.
Up to you what you do with it.
I am trying to test embedded devices that can send emails. They connect
to an email server to store and forward the emails.
I have a shared computer used in the tests. The embedded device is given
the IP address and port of the email server on the shared computer.
1. Since lots of developers can be using the shared computer (including
jenkins), I need the developer to startup, run, and shutdown the email
server using a random port that is not privileged.
2. My test system needs to be contained and not dependent on the host
system. Some of the products develop for a while then go dormant, only a
few years later to be resurrected, hence containers with the test
environment (and build environment).
3. My device needs to do three different kinds of email:
- plain TCP/IP socket with everything in the clear (yuck but I am
stuck with it)
- SSL server email
-TLS server for the email.
I have been able to get TCP going, but the SSL and TLS servers are not
working yet.
4. I have also tried setting up a subsystem test of my email server. The
container running the email server also runs an email client with
network=none (127.0.0.1 works). This allows us to have tests of the
common code (email server) that is not dependent on any device. Again I
got unencrypted working but not encrypted.
5. Our emails or both traditional text only emails, and HTML emails. I
have not tried extracting the pictures we attach to our HTML emails yet,
only working with text only ones.
Kendrick
…On 2021-10-19 12:19 a.m., Pandu E POLUAN wrote:
Ah, that's a new use case for me (setting port to 0)
Currently the code for |Controller| tries to connect to the specified
port
<https://urldefense.com/v3/__https://github.com/aio-libs/aiosmtpd/blob/master/aiosmtpd/controller.py*L416-L429__;Iw!!IOGos0k!31txFYuY9Rc4NFdQOkPOI0ejKqDtP3Cs3HXdjS2z64ULuOWGLtzGdODCN72pTf5W_suHBw$>
to trigger the server to activate once. It is a simple mechanism and
does not consider the special |port=0| case.
I'll see if I can add more intelligence to |_trigger_server()|
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://urldefense.com/v3/__https://github.com/aio-libs/aiosmtpd/issues/276*issuecomment-946401243__;Iw!!IOGos0k!31txFYuY9Rc4NFdQOkPOI0ejKqDtP3Cs3HXdjS2z64ULuOWGLtzGdODCN72pTf5akcxw-A$>,
or unsubscribe
<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AR3ZTVLW3XVFPVDQACMPVODUHUEX7ANCNFSM47EI37RQ__;!!IOGos0k!31txFYuY9Rc4NFdQOkPOI0ejKqDtP3Cs3HXdjS2z64ULuOWGLtzGdODCN72pTf5yHTvXEw$>.
Triage notifications on the go with GitHub Mobile for iOS
<https://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!IOGos0k!31txFYuY9Rc4NFdQOkPOI0ejKqDtP3Cs3HXdjS2z64ULuOWGLtzGdODCN72pTf5Hv8A5Kg$>
or Android
<https://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!IOGos0k!31txFYuY9Rc4NFdQOkPOI0ejKqDtP3Cs3HXdjS2z64ULuOWGLtzGdODCN72pTf7Bp4KCww$>.
|
FWIW you can check out how I create an ssl server https://github.com/waynew/orouboros/blob/89905978a423e130e9ea2c57690b2e4a6cc48f3d/orouboros.py#L313 |
I've also run into this problem while trying to prepare pytest-dev/pytest-localserver for the removal of I'll probably wind up regretting saying this 😛 but it seems like a simple fix, just replace |
...and almost immediately I figured out why it's not that simple, with the mixing of synchronous and asynchronous code 😆 I knew I shouldn't have said anything. But I would still be quite willing to put some time into this, if it'd help. |
Okay, so.... I know it's been a very long time since I've touched this, but - yeah, the fix is pretty straightforward, I think. First off, yeah I was able to reproduce this. Second off, I think the correct thing for us to do here is in the
By making that change locally, it all worked 👍 We'll want some test cases for that obviously, but it shouldn't be too hard to do! |
Well, heck! The fix was pretty easy, though I did have to move the change to _trigger_server. But I'm struggling with the test cases -- I think we actually have some tests that are failing on some more modern Pythons anyway 🤔 |
Hopefully this will work out; thank you for look into it. |
I am trying to develop a test email server that should run in a docker container. The docker container is run with --network=host -P; though for unit tests I would like to use --network=none.
I am deliberately specifying that port 0 should be used (let the OS pick an available port). I then have a function to get the port that was actually used. The server code is
I keep getting connection refused
when running inside a docker container. If I run on the host then the server starts up fine.
(My host and container are both Ubuntu 20.04, python 3.8.5, the container has aiosmtpd 1.4.2 installed from source).
The text was updated successfully, but these errors were encountered: