I have a server (say server A) where I configured a private MSMQ for queueing the messages and deployed an application on another server (say server B) to send messages. Server A and server B are not in the same network or domain. We have opened port 1801 on server A for the communication with MSMQ.
And we are using below code for sending messages from Server B to Server A
var queue = #"FORMATNAME:DIRECT=TCP:<remote_server>\private$\<queuename>";
var messageQueue = new MessageQueue(queue);
var message = new Message("Hi Message");
messageQueue.Send(message);
It is working fine if I send messages from Server B to the remote server A.
But if I try to delete all messages from the queue using the application hosted on the server A,it will throw the below exception
remote computer is not available.
I am using the below code for purging the queue.
var queue = #"FORMATNAME:DIRECT=TCP:<remote_server>\private$\<queuename>";
var messageQueue = new MessageQueue(queue);
messageQueue.Purge();
I have set below two properties [UrQueueName] -> Properties -> Security for testing
Set Everyone to Full Control
Set ANONYMOUS LOGON to Full Control.
How can I find out what the exact issue with purging, as I can send the messages to this remote server?
Do I need to open any other ports for purging other than 1801?
Related
Server.cs - https://hastebin.com/enajinewij.cs
Client.cs - https://hastebin.com/iriperubur.cs
I have tried both running the Client on another PC and running it on one PC, but both result in the Client not being able to receive or send any messages.
I CANT portforward. I am using Hamachi for the IP Address. Both client and server are connected to my Network and are using the Hamachi IP Address. I am using PDA Net to connect to the internet from my PC.
The Server does not see them connect at all. Nor does the Server get any messages from them. Currently only the Server can send messages, and only it can get them.
I am not getting ANY errors at all, so I am not sure how I should handle solving this issue as it's my first time working with networking.
At first you create a TcpListener and you call StartLis() that does BeginAcceptTcpClient. However in AcceptTCPClient you create a new TcpListener and BeginAcceptTcpClient is not called.
You don't have to create a new listener for each connection, but you do have to call BeginAcceptTcpclient again:
private void AcceptTCPClient(IAsyncResult ar)
{
TcpListener Lis = (TcpListener)ar.AsyncState;
Clients.Add(new ServerClient(Lis.EndAcceptTcpClient(ar)));
StartLis(); // this will call BeginAcceptTcpClient again
}
I use the trial of PowerWebSocket API
https://www.noemax.com/powerwebsockets/
I want connect a Client to the Server, but the server is on a remote machine.
Server
var server = new WebSocketServer();
server.AddEndpoint<LevelOneWS>("http://localhost:30000");
server.Open();
Client
var LevelOne = new WebSocketClient<TickService>http://www.xxx.yyy.zzz:30000);
LevelOne.Open();
The port 30000 is open on the server, client, router/modem (with redirection).
But I can't connect to server, AddEndPoint cant connect, server dont accept the connection.
On the same computer, full localhost, its perfect.
I think the error is, that your server listens on localhost, that means the internal loopback interface: 127.0.0.1 It should listen on it's external interface.
I have a server object as
TcpChannel tcp = new TcpChannel(1234);
ChannelServices.RegisterChannel(tcp, false);
string s = ConfigurationManager.AppSettings["remote"];
RemotingConfiguration.RegisterWellKnownServiceType(typeof(TestRemoting.InitialClass1), "TestRemoting", WellKnownObjectMode.Singleton);
Console.WriteLine("Server is running on 1234 channel...");
Console.WriteLine("Press Enter to Stop");
Console.ReadLine();
and I am accessing that object in mu client form like
InitialClass1 Icls = (InitialClass1)Activator.GetObject(typeof(InitialClass1), "tcp://localhost:1234//TestRemoting");
Now I am keeping my remote object in another computer. How can I access my server object from that computer. If I access the server object from my (local) computer, I will use
"tcp://localhost:1234//TestRemoting"
I am using localhost here, because my server object and my client is same. So If those two are different, How can I access the server object.
I tried with my another computer IP
as
tcp://200.100.0.52:1234//TestRemoting
that time I am getting an exception as
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 200.100.0.52:1234
The message means most of the time that the client cannot find the service. You can use the following steps to determine where the connection fails:
Check if the service is running on the remote machine.
Check if the port number is correct.
Ping the remote machine from the client.
Open a telnet session to the remote machine on the port number of service.
The step on which it fails gives an indication of why it is failing.
There is a remote machine (let's call it MSMQ machine) which has MSMQ installed on it and is used by several other processes. I would like to read the messages on a given private queue of the MSMQ machine from my local machine - BUT, I would like to avoid installing Message Queuing on my machine, since what I need is simply to check and monitor the messages. I will not send nor receive messages (at least won't store them), I just want to "peek" at them.
Is there any way to do this? I have a code more a less like this now:
public string CheckMessageQueue(machine, queue)
{
StringBuilder Ret = new StringBuilder();
var path = machine "\Private$\" + queue;
try
{
MessageQueue mq = new MessageQueue(path);
Message msg = new Message();
msg = mq.Peek();
Console.WriteLine(msg.ToString());
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
if I run the code above I get the error message
"Message Queuing has not been installed on this computer."
No, there is no other way than installing MSMQ on your local machine as well. The client libraries uses the local server to communicate with remote servers.
I have a private queue on a remote machine that everyone and the anonymous login have full access to. The following code produces and error when trying to receive:
var qpath = #"FormatName:DIRECT=TCP:xx.xx.xx.xx\PRIVATE$\QueueName";
var q = new MessageQueue(qpath);
var msg = new Message();
msg.AttachSenderId = false;
msg.Recoverable = true;
msg.Body = "hello";
q.Send(msg); // <-- this works!
var recMsg = q.Receive(TimeSpan.Zero); // <-- this breaks! :|
The Error message is: Message Queue service is not available.
The sent message are ending up in the queue on the remote machine
The same happens when using OS:MachineName instead of TCP:xx.xx.xx.xx
The queue server is not part of the domain.
Any ideas?
If the remote machine is part of a different domain then:
MSMQ 3.0 applications running on cross-forest computers running a member of the family in non-trusted domains will use the secured remote read API. By default, the MSMQ 3.0 server hosting the queue containing the message to be read requires other domain computers making read requests to establish an encrypted channel, but such a channel cannot be established between non-trusted domains. Thus, remote read requests from cross-forest computers will be rejected. To modify this default behavior and allow the Message Queuing server to accept requests from domain computers that do not establish an encrypted channel, add the
HKLM\SOFTWARE\Microsoft
\MSMQ\Parameters\Security\NewRemoteReadServerAllowNoneSecurityClient
registry entry (a DWORD) and set it to 1.
This is form: Reading Messages from Remote Queues.