eclipse / paho.mqtt.m2mqtt

Eclipse Public License 1.0
512 stars 303 forks source link

broker on local pc - as string format unknown, or not accepted #51

Open vincentnl opened 7 years ago

vincentnl commented 7 years ago

I am trying out the client;

The code below will run, without a hitch, although it is deprecated. When I try it with 'server' directly (as commented out below), it won't fly.

What is the format needed to indicate a host on the local network? (server.homenet also didn't take)

Tx

if (_mqttClient == null)
            {

                try
                {
                    //IPHostEntry entry = Dns.GetHostEntry(ipaddress);
                    IPAddress[] ip = Dns.GetHostAddresses("server");
                    IPAddress ipaddres = ip[2];
                    _mqttClient = new MqttClient(ipaddres);
                    //_mqttClient = new MqttClient("server");
                    _mqttClient.MqttMsgPublishReceived += _mqttClient_MqttMsgPublishReceived;
                    _mqttClient.Connect("TestClient");
                }
                catch (Exception ex)
                {

                }
}