MSMQ cannot connect to remote server exception and receiving send failure - msmq

I've wrote a sample c# program to send/receive messages. To connect I use this:
.\Private$\NeilQueue
the queue exists and it works find.
The computer in question's name is WORKST5377
So I tried to connect using this string:
FORMATNAME:DIRECT=OS:WORKST5377\Private$\NeilQueue
But I get an exception of remote computer is not available when I try to retrieve the message. However, I don't get any error when I call Send()
Is there something wrong with my connection string or is it something as simple as I cannot do this for the machine it is running on? I haven't got a remote computer to test on now, I just want to ensure the connection works using the proper connection string.
Also, how do you tell if a message was actually sent to the queue? I tried:
mm.AcknowledgeType = AcknowledgeTypes.NegativeReceive;
mm.UseDeadLetterQueue = true;
mm.TimeToReachQueue = TimeSpan.FromSeconds(5);
mm.UseJournalQueue = true;
but nothing was put in the journal queue. It only did a negative when I set UseDeadLetterQueue - or is this how you do it?
thanks.

Related

Not possible to use server after db = server.use?

I was doing a very basic test using node.js, latest orientjs and latest OrientDB:
open server (using port 2424)
assign db (server.use)
server.list()
If I do this, the promise at server.list() hangs and the server shows the error "Impossible to read a chunk of length...". But if I just don't assign the db, it works fine. Also, if I call db functions (like db.record.get) instead of server.list(), that works fine too.
Is it the case that you can't call a server function after calling server.use?
On a related point, is there a way to set a network timeout for orientjs? If I try to do any of this and the target server is not reachable, it just hangs on opening the server and/or assigning the database.

Query on Ratchet Socket

I am using Ratchet Socket. I have established a new server connection and I want to stop server from running. In this scenario I have IP(Hostname) and port with me, So how can I stop that?
Is it possible to make a server connection that never ends?
When I make a server connection, first day the data output is perfect from DB, But on second day, the error is generated as "Connection is closed by foreign host". But still I can connect to that port.
Code
<?php
use Ratchet\Server\IoServer;
use MyApp\Chat;
use React\EventLoop\Factory;
use React\ZMQ\Context;
require dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/src/MyApp/Chat.php';
$server = IoServer::factory(
new Chat(),
6666
);
$server->run();
?>
1.
I am using Ratchet Socket. I have established a new server connection
and I want to stop server from running. In this scenario I have
IP(Hostname) and port with me, So how can I stop that?
I assume that you currently run your Ratchet server by running it as a php script in a terminal window or screen.
eg: php push-server.php
Once you stop running the script your server will stop.
2.
Is it possible to make a server connection that never ends?
Yes, if your php script stops working from the terminal, you have to manually restart it. Its better to use a program like Supervisor (A Process Control System) which is recommended by Ratchet.
Check this link for more info http://supervisord.org/installing.html
The supervisord service will monitor your php script and will automatically restart it if it crashes which is suited for production environments.
3.
When I make a server connection, first day the data output is perfect
from DB, But on second day, the error is generated as "Connection is
closed by foreign host". But still I can connect to that port.
This is quite common and I've noticed it too. It usually happens when the server is heavily loaded or times out. Your JavaScript should check for this message and re-initiate a new connection if you see this message. You can also get it to try again after a random timer as well.
Edits
Also the __construct method for the Ratchet\Server\IoServer requires 3 prams, of which the 3rd one being optional. The first and second need to be objects of MessageComponentInterface and ServerInterface.
public function __construct(MessageComponentInterface $app, ServerInterface $socket, LoopInterface $loop = null) {
The way you instantiate the IoServer seems incorrect.

MSMQ messages disappear when they get to remote server

I have to create a MSMQ messaging mechanism between two servers in the same domain, SenderServer (MS Server 2012) and ReceiverServer (MS Server 2008 R2).
I created a private, transactional queue in ReceiverServer .\private$\receiver, I gave receive (and peek) message rights to system and administrators.
I then created a client application that creates and forwards messages to the queue by using the following code:
MessageQueue queue = new queue("FormatName:Direct=OS:ReceiverServer\private$\receiver");
Message message = new Message();
message.Body = "myMessage";
using (MessageQueueTransaction tx = new MessageQueueTransaction())
{
tx.Begin();
queue.Send(message, "myLabel", tx);
tx.Commit();
}
Before deploying the application, I tested it from my machine (Windows 7) that correctly creates an outgoing queue Direct=OS:ReceiverServer\private$\receiver with State:Connected and Connection History:Connection is ready to transfer messages.
The messages are correctly sent to the ReceiverServer and placed in the \private$\receiver queue. The End2End log of the ReceiverServer for every message logs two events:
Message came over network (EventId: 4)
Message with ID CN=msmq, CN=[mymachinename], CN=Computers, DC=[domain], DC=[other] was put into queue ReceiverServer\private$\receiver (EventId: 1)
Then I used the client application from within the SenderServer using the same code. The server correctly creates an outgoing queue Direct=OS:ReceiverServer\private$\receiver with State:Connected and Connection History:Connection is ready to transfer messages, I can see the message queuing up and be sent but I do not receive them in the remote ReceiverServer queue .\private$\receiver. If I check the End2End event log of the ReceiverServer I just see the first message (Message came over network (EventId: 4)) but the message is not placed in the queue.
I turned off firewalls from both machines, changed the authorization settings for the queue and tried the following endpoint for the queues:
FormatName:Direct=OS:[IPv6 address]\private$\receiver
FormatName:Direct=TCP:ReceiverServer\private$\receiver
FormatName:Direct=TCP:[IPv6 address]\private$\receiver
With no luck. The troubleshooting process and the documentation from Microsoft are really general and simplistic, therefore I decided to ask here because for me is a dead end.
The sender domain account needs to have the following permissions on the remote queue: Send, Get Permissions, Get Properties
Are these machines on the same domain? If not you may need to grant the above permissions to the local user called ANONYMOUS LOGON
I ran into a similar problem and spend a few hours resolving it, so I wanted to post an answer to save others who may fall into the same trap I did.
When the queue was created on the remote server, it was mistakenly created as a transactional queue. However the code that was posting the messages was calling send without the transaction parameter. I could see the message at the sending workstation, but once it hit the destination server, it would disappear without any logging, journaling, or events to help determine why.
Once I identified the problem, I recreated the Queue as a non-transactional queue, and the issue was fixed.

How to enable client side debug printout

I installed the latest quickfix on a virtual machine environment, it does not work properly. Here is what I found:
1. At server side I run run_executor_python.sh
2. At client side I run run_tradeclient.sh
Server side does not receive anything - I know this because if it does, it prints out the received message.
I modified cfg/tradeclient.cfg and set the SocketConnectHost to 127.0.0.1 and start server at the same VM, this time I can see the server receives messages. So this means my installation is good.
I am wondering if there is some command option I can set so that clientside can print out some status or error message which can help me trace where the problem is. I tried run "./tradeclient -h", but "-h" is not a valid option.
My colleague did the same setup as I did and it worked for me, the only difference is his is on real machines, instead of virtual machines. Do you know if there is known problem on VM? Google does not return anything.
Anyway, thanks a lot.

MSMQ - Create and Send Message

I have a public queue created in a remote machine. I am able to access the queue, create a message and send it from my workstation. However, when I access the remote machine that hosts the message queue, I do not see any messages. Any ideas on what I am missing? Is there anything that need to be configured to receive messages?
You should check the security settings on the remote queue - the default setting for any account is "allow sending only".
I got it to work by removing MessageQueueTransactionType.Single from MessageQueue.Send(message,MessageQueueTransactionType.Single) method.
It Seems like there was a mismatch between the Transaction types. I am still not familiar how the transaction types work.