Listener#
The ngrok Agent SDK for Python
- class ngrok.Listener#
An ngrok listener.
- close()#
Close the listener.
This is an RPC call that must be .await`ed. It is equivalent to calling `Session::close_listener with this listener’s ID.
- forward(addr)#
Deprecated since version 0.10.0.
Use
listen_and_forward()
on Listener builders instead, for exampleHttpListenerBuilder.listen_and_forward()
.Forward incoming listener connections. This can be either a TCP address or a file socket path. For file socket paths on Linux/Darwin, addr can be a unix domain socket path, e.g. “/tmp/ngrok.sock”.
- forwards_to()#
Returns a human-readable string presented in the ngrok dashboard and the API. Use the
HttpListenerBuilder.forwards_to()
,TcpListenerBuilder.forwards_to()
, etc. to set this value explicitly.To automatically forward connections, you can use
listen_and_forward
, orlisten_and_serve
on the Listener Builder. These methods will also set this forwards_to value.
- id()#
Returns a listener’s unique ID.
- join()#
Wait for the forwarding task to exit.
- labels()#
The labels this listener was started with.
- metadata()#
Returns the arbitrary metadata string for this listener.
- proto()#
The protocol of the endpoint that this listener backs.
- url()#
The URL that this listener backs.