MSMQ private queue issue between two domains - msmq

My local machine is on domain A, my simple console application tries to put a message onto a private queue of a remote machine, which is on domain B. In the outgoing queues the status shows connected but the message does not seem to go. On the receiving side, the private queue does not seem to be receiving the message. The permissions for the private queue is set to full control for Everyone,Anonymous log in and System.

You can try to Impersonate to the user for domainb first (see http://blogs.msdn.com/b/joncole/archive/2009/09/21/impersonation-code-in-c.aspx)
and then make the call(s) to the remote queue
Not 100% sure if that will work though.

It's to do with NAT, if the receiver machine is behind a NAT, you can not send MQ to it.
The work around is to specify a public IP on the receiver machine and use direct TCP address format which is 'FormatName:DIRECT=TCP:{remoteIP}\private$\{QueueName}'
Forexample:
FormatName:DIRECT=TCP:200.201.202.203\private$\mqReceiverQueue

Related

How to check whether user already authenticated via UDP

Suppose that I have to write a UDP server which should receive authentication token for each client in the first message and then receive different data after some period of time. This UDP server should obviously check whether certain client authenticated previously or not. How should I do it? Should I store "authenticated" flag for each (IP addr, port) pair? Is it ok? If so, what will happen if several clients will have the same IP address (for example, they share it from the same internet provider)?
I think you can't. You'll need to have the token in each message. Multiple requests can come from the same IP, such as a client connecting from behind a NAT.
This a rare case where you might want to use multiple UDP sockets at the server and connect() each of them to one authenticated client, so that you can only receive further messages on each one from each authenticated client. You'll have to send the first reply via hat socket,a denture client will have to be written to adjust its destination accordingly after receiving the first reply.

Postfix relaying via specific outgoing IP

I've been pulling my hair getting this to work but i have a problem with the sender_dependent_default_transport_maps:
Sending a mail via the specific postfix works like it should the correct outgoing transport is used. But when the situation is as follows:
externally received mail from somewhere (external#gmail.com) to my local (virtual) address (local#local.com) which should forward to i.e. final-destination#gmail.com doesnt get routed using the sender_dependent_default_transport_maps...
i.e. i've configured local.com to use a specific IP. Logging into the server and sending it directly works... BUT when when deliverying a relayed mail the transport is ignored...
Is there a way to adhere to the sender_dependent_default_transport_maps when relaying?
I've worked around my question: by rearranging the eth-configs i've managed to change the default outgoing IP for relayed mail...
Sigh...

Why does sending an email need multiple mail server hops?

When I send an email to somebody, (I think) my email is sent to my home server, then the email is sent to target server, then it is finally sent to the people I want to send to.
Sometimes, this needs multiple hops, which is the point that confuses me. Why does this need multiple hops? Why can't the email be sent to the target server directly? XMPP doesn't need multiple hops, for example.
A typical email transaction uses an outbound mail server, which looks up your recipient's incoming server, delivers it there, then that server hands it off to your recipient's mailbox server. That's 3 hops:
When you send a message, you connect from your email client (more properly: mail user agent, MUA) to your outbound SMTP server. This is the first hop, and your SMTP server creates a Received header denoting it for auditing later on. This will include the IP it sees you connecting on, a message ID internal to that specific server, and sometimes some other information.
Your outbound SMTP server then looks up the MX (mail exchange) record for each recipient's domain in DNS and connects to the highest priority relay it can find (the numerically lowest MX priority) for them. This is the second hop. As with any hop, a Received header is added.
The MX relay typically does anti-spam filtering, potentially rejecting the message during the SMTP connection. This is what generates a bounce message, which your outbound SMTP server sends you directly (if it's sent across the internet, it risks being backscatter, a form of spam, because the bounce cannot be proven to be legitimate). Often, anti-spam filtering is done later and the message is dropped silently or else delivered with markup.
The MX relay then hands the message off internally to your mailbox (IMAP/Exchange) server (hop #3). Sometimes, local mailbox server filters are used to handle patterns (or markup from the MX server) and facilitate various actions such as filing suspected spam into your Junk folder.
If you use a mail forwarding service, the MX relay instead passes your message to the forwarding target (another MX relay). This can theoretically go on for quite a while or even loop infinitely, but it should eventually end in a mailbox server.
See also the formal SMTP specification, RFC 5321.
If you use webmail, the web mail server is your email client. Some web mail servers add headers resembling Received headers to track the connection so spam filters can extend their reputation checks to the user rather than to the webmail system, which could be characterized as yet another hop.
In enterprise-grade environments, it is common for multiple layers of servers to be used for various purposes. These extra hops happen between the MX relay and the mailbox server and can be related to extra anti-spam or anti-virus handling, advanced mail aliasing, email archiving, internal mail routing between campuses, or any number of other things. These can for example ease transitions from one mail system to another (like migrating between versions of Exchange, which may require lots of testing and a slow migration so a problem doesn't affect the whole company).
Fundamentally that has to do with the original purpose of the Internet, or rather it's predecessor ARPANET, was designed to survive the loss of portions of the network (popular to popular misconception, this design goal existed not in order to survive nuclear attack, but because network components were rather unreliable at the time).
The packet switching network is designed to find one or more routes from where the packet starts (your email client) to where it needs to be (the email client of the person you are sending to).
In order to achieve that flexibility, the system is designed not just to route directly from point A to point B, but to find an available route (from a possibly very large set of possible routes) that is currently functioning.
If your email client had to know how to directly send to every other device in the world, without intervening subnets managing traffic, your computer would need a direct connection to every other computer in the world. That would be prohibitively expensive. Instead, routers inbetween accept packets from you and other people in your area and figure out how to route each packet closer to its destination. That's similar to the method that the airlines use to have regional flights feed hubs.
When a packet is being routed through the internet it will make multiple hops to get from source to destination.

MSMQ messages disappear from outbound queue but never arrive in the inbound queue

I have a strange issue setting up an existing application on our new internal Cloud.
I have a simple messaging system that pushes a message from one server (Server1) onto a MSMQ on another server (Server2). The messages disappear off the outbound but never appear in the inbound queue.
When I take Server2 msmq off line the messages build up on Server1. Restarting Msmq on Server2 causes the messages in the outbound queue on Server1 to disappear - but the message still never arrives at Server2.
The details:
MSMQ is set up in Workgroup mode, as that's the virtual networks requirement.
Queues are private.
Permissions are set to allow certain users access.
Has anybody any ideas on why this is happening or how I could track down the issue.
It could be that the remote private queue is a transactional queue and you send the message as non-transactional or vice versa. If the transaction setting on the queue and the message does not match, the message will disappear!
I have seen this in the past with the direct format name where it was set to something like
DIRECT=OS:192.16.8.0.1\PRIVATE$\MyQueue
where I should have specified DIRECT=TCP:192.168.0.1\PRIVATE$\MyQueue
see:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms700996(v=vs.85).aspx
#John Breakwell had noted here http://blogs.msdn.com/b/johnbreakwell/archive/2010/01/22/why-does-msmq-keep-losing-my-messages.aspx:
Server name used to address message doesn't match destination machine
When MSMQ receives a message from over the wire, it always validates that this machine is the correct recipient. This is to ensure that something like a DNS misconfiguration does not result in messages being delivered to the wrong place. The messages are, instead, discarded unless the IgnoreOSNameValidation registry value is set appropriately. You may want to do this with an Internet-facing MSMQ server, for example, where the domain and server names visible to MSMQ clients on the Internet often bear no resemblance to the real ones (for good security reasons).
It sounds like a permissions or addressing issue.
Try to enable the event log under Applications and Services Logs -> Microsoft -> Windows -> MSMQ called End2End.
This log should tell you exactly what is going wrong with the delivery of messages to the expected destination queue.
Nope: For every successful delivery there should be three events raised in this log:
Message with ID blah came over the network (ie, message has arrived from a remote sender)
Message with ID blah was sent to queue blah (ie, message forwarded to local queue)
Message with ID blah was put into queue blah (ie, message arrives in local queue)
Assumes you are using Server 2008 and above.
You can add Negative Source Journaling to the sending application code to find out exactly what the root cause is. Most likely one of the two answers you have already received.
Are the messages arriving in the dead-letter queue on Server 2?

Should I use IIS Virtual Server Relay or Connect to SMTP Server directly?

I have an e-mail account with hostgator. I would like to build a console application (later a service application) that will check a mysql database for e-mails that need to be sent out and will process them by sending a certain number of e-mail every so many seconds. These e-mails will each have a 2-3mb pdf price sheet attached to be sent to our regular customer base. About 500 are set up to receive e-mails.
My question is: Should I connect to hostgator directly and send the
e-mails or should I use the IIS Virtual Server Relay and have it
connect to hostgator?
The only thing I can think of is if Hostgator were down the virtual relay might be a good option since it has retries. There again, I guess I could put some try/catch in the code where if it doesn't connect to hostgator or if their is a problem it will go to the timer and wait x minutes before retrying to process e-mails.
We have found that the easiest approach is to generate the outgoing emails and drop them in the inetpub\mailroot\pickup folder and let the SMTP service handle them (you can set it up to forward the emails to the appropriate host).
This falls firmly under the category of not re-inventing the wheel: the SMTP service easily handles the situation when the connection to the mail server is down, retries, and all of the other "fun" stuff that you would otherwise have to implement in your code if you handle the SMTP sends directly.