I've setup a openfire server in a vm, and its accessible from internet(I've done the port-forwarding to point to the ip of the vm).
I can chat using spark so openfire is working perfectly.
Now I am trying to connect my c# app to the server and I am getting error.
Code :
private void button1_Click(object sender, System.EventArgs e)
{
try
{
using (var client = new XmppClient("192.168.0.109", "pbc92", "12345"))
{
try
{
client.Connect();
client.StatusChanged += client_StatusChanged;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void client_StatusChanged(object sender, S22.Xmpp.Im.StatusEventArgs e)
{
MessageBox.Show(e.Jid.ToString());
}
The error :
Try with Sharp.Xmpp, it is a fork of the currently frozen S22.Xmpp.
https://github.com/pgstath/Sharp.Xmpp
Related
I am using the below code snippet while trying to connect to remote server in visual studio, but it is not working, please suggest.
private void bttnConnect_Click(object sender, EventArgs e)
{
try
{
RDP_client.Server = txtServerName.Text;
RDP_client.UserName = txtUserName.Text;
IMsTscNonScriptable secured = (IMsTscNonScriptable)RDP_client.GetOcx();
secured.ClearTextPassword = txtPassword.Text;
RDP_client.Connect();
if (RDP_client.Connected.ToString() == "1")
{
MessageBox.Show("connected");
}
else
{
MessageBox.Show("not connected");
}
}
catch (Exception ex)
{
MessageBox.Show("unable to connect"+ex);
}
}
I am developing a windows form to function as a modbus tcp Master Simulator.I am using NModbus library.
I want to connect to multiple slaves simultaneously and do the read and write operation,does the NModbus library supports this kind of implementation? and if so how?.
Currently i am able to connect to single slave device and do the read/write operations,but i am stuck on how to the same with multiple slaves though.
Should i use the threading Concept to achieve the same.
Here is my code to connect to single slave device and do the read/write operation.
private void btnConnect_Click(object sender, EventArgs e)
{
try
{
TcpClient masterTcpClient = new TcpClient(txtIP.Text, 502);
master = ModbusIpMaster.CreateIp(masterTcpClient);
MessageBox.Show("Connected");
}
catch (SystemException error)
{
MessageBox.Show(error.Message);
}
}
private void btnReadCoil_Click(object sender, EventArgs e)
{
try
{
byte slaveID = 255;
ushort startAddress = Convert.ToUInt16(txtStartaddress.Text);
ushort numInputs = Convert.ToUInt16(txtSize.Text);
bool[] inputs = master.ReadCoils(slaveID, startAddress, numInputs);
AnswerFromServer.Items.Clear();
for (int i = 0; i < inputs.Length; i++)
{
AnswerFromServer.Items.Add(Convert.ToInt16(inputs[i]));
}
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "Exception Reading values from Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnWriteSingleRegister_Click(object sender, EventArgs e)
{
try
{
byte slaveID = 255;
ushort RegisterAddress = Convert.ToUInt16(txtStartaddress.Text);
ushort value = Convert.ToUInt16(txtSingleValue.Text);
master.WriteSingleRegister(slaveID, RegisterAddress, value);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "Exception writing values to Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Can any one please help me with this one?
create another instance of this socket and maintain it.
TcpClient masterTcpClient_Two = new TcpClient(txtIPTwo.Text, 502);
Hello I am new to this but I am developing a client to Mosquitto broker.
It works fine, but I want to know how could I add the Sender Id to the message.
i.e. Message From "Client1" : "LightON"
This is how I handle the subscription
private void Form1_Load_1(object sender, EventArgs e)
{
try
{
IPAddress HostIP;
HostIP = IPAddress.Parse(textBox1.Text);
clientSub = new MqttClient(HostIP);
clientSub.MqttMsgPublishReceived += new MqttClient.MqttMsgPublishEventHandler(EventPublished);
}
catch (InvalidCastException ex)
{
MessageBox.Show("ERROR ON LOAD" + ex.ToString());
}
}
The Publish Event is :
private void EventPublished(Object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
{
try
{
SetText("Recevied Message..");
SetText("The Topic is:" + e.Topic);
SetText("*Message: " + System.Text.UTF8Encoding.UTF8.GetString(e.Message));
SetText("");
}
catch (InvalidCastException ex)
{
}
}
And I am using the M2mqtt library.
The only way to do this is to add it to the message payload yourself.
There is no concept of a publisher id in the MQTT headers. Client IDs are only to identify clients to the broker, not end to end.
I just created 1 simple C# app reading data from serial port (baudrate 57600). When I send file data from another computer through serial port, CPU worked >90%. How can I solve that ?
EDIT:
private void btn_Start_Click(object sender, EventArgs e)
{
if (temp_portname != null)
{
//ポート設定
SerialPort.PortName = PORT1;
SerialPort.BaudRate = 57600;
//ポートを開く
try
{
SerialPort.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
the problem is : the remote server returned an error :NotFound
private WebClient client = new WebClient();
private string siteUrl = "http://www.google.com/";
// Constructor
public MainPage()
{
InitializeComponent();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(new Uri(siteUrl));
}
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
try
{
if (e.Error == null)
{
webClientResults.Text = e.Result;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Check the network connectivity in your device. Such error occurs mainly when there is no proper internet connectivity is not available.
There is no problem in your code.