Content-Length: 266509 | pFad | http://github.com/eclipse-paho/paho.mqtt.python/issues/873

B1 open connection with custom socket · Issue #873 · eclipse-paho/paho.mqtt.python · GitHub
Skip to content

open connection with custom socket #873

Open
@LibraryRaven

Description

@LibraryRaven

Feature Description

I would like to be able to connect with a manually provided socket.

This would enable me to tunnel MQTT through an SSH connection with paramiko.

import paramiko

# connect to SSH gateway
sshclient = paramiko.SSHClient()
sshclient.connect("sshgateway.example.org", "user", "password")

def create_socket():
  # open tunnel to the internal MQTT port
  return sshclient.get_transport().open_channel('direct-tcpip', ("127.0.0.1", 1883), ('', 0))

import paho.mqtt.client as mqtt
mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
mqttc.connect("127.0.0.1", transport="callback", create_socket=create_socket) 

Requested Solution

import socket

def create_socket():
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  sock.connect(('mqtt.example.org', 1883))
  return sock

import paho.mqtt.client as mqtt
mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
mqttc.connect("mqtt.example.org", transport="callback", create_socket=create_socket) 

Alternatives

For now, I can use my own SocketedClient class, which inherits Client and uses a provided create_socket function on connect() and reconnect().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: AvailableNo one has claimed responsibility for resolving this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://github.com/eclipse-paho/paho.mqtt.python/issues/873

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy