[Twisted-Python] Can transport.write() to hostname instead of IP address?

Adi Roiban adi at roiban.ro
Thu Aug 16 18:49:49 MDT 2018


On Fri, 17 Aug 2018 at 01:25, Sean DiZazzo <sean.dizazzo at gmail.com> wrote:
>
> Hi all!
>
> After I start a reactor connecting to a specific hostname and port, I do my thing and then call transport.write() to send the data to the peer.
>
> From what I can tell, though, the hostname is resolved, and the data is written back to the ip address itself, instead of the hostname I started the reactor with.
>
> This is a problem in my case because we are using nginx's ssl_preread server_name directive to route several different streams all coming in on the same ip address.
>
> So the write() method needs to explicitly use the hostname to route the packet properly.
>
> So... Is there any way to have transport.write() use the hostname given instead of it's resolved IP address? Or am I missing something?
>

I assume you are using TCP here.

I guess that you are missing something.

If you want each write to go over its own way / route and have the
hostname re-resolved you should open + write + close a connection for
each write.

But I think that there is something else there and this is now what you want :)
Do you use HTTP or have a custom protocol?

Cheers,

Adi Roiban




More information about the Twisted-Python mailing list