SzymonPobiega / NServiceBus.Router

Cross-transport, cross-site and possibly cross-cloud router component for NServiceBus
MIT License
5 stars 10 forks source link

SQS/SNS - MSMQ - Router not working behind a proxy #44

Open rhg1968 opened 3 years ago

rhg1968 commented 3 years ago

I have successfully implemented an endpoint (v7.5.0 using .net 4.8) that runs on a windows server and utilizes the router to bridge between the MSMQ and AWS. It runs correctly from multiple developers machines but we have into some issues moving it into our development environment. In our dev environment we have added the SQS queues urls to the proxy and the generic SNS url us-east-2 to the proxy as well. I also have both the router and endpoint itself setting up the client factory to configure to use the SQS client with a SQS config object to set the properties for the proxy.

When we run this all the SQS queues get created properly from behind the proxy, but the SNS topics and subscriptions are not created from behind the proxy. Looking at CloudTrail I don’t see any SNS activity except from our local machines.

I wanted to see if there is anything special with the SNS component that needs to be configured differently for it to work from behind a proxy. I am already doing custom config on the router so it will work based on previous responses to questions I have posted in the forums.

            extensions.ClientFactory(() => {
            return (!useProxy)? new AmazonSQSClient(): new AmazonSQSClient(new AmazonSQSConfig
            {
                ProxyHost = proxyUrl,
                ProxyPort = proxyPort
            });
        });

        var ctor = typeof(MessageMetadataRegistry).GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new[] { typeof(Func<Type, bool>) }, null);

pragma warning disable CS0618 // Type or member is obsolete

        settings.Set<MessageMetadataRegistry>(ctor.Invoke(new object[] { (Func<Type, bool>)isMessageType }));

pragma warning restore CS0618 // Type or member is obsolete

Update - 9/13/2021 It appears as though the SQS traffic is https and is successfully going through the proxy. The SNS traffic appears to be going through the firewall as tcp over port 443.

rhg1968 commented 3 years ago

Got it working with help from the community and Particular. Just has to also configure SNS with the client factory transport.ClientFactory(()=>new AmazonSimpleNotificationServiceClient( new AmazonSimpleNotificationServiceConfig { ProxyHost = proxyUrl, ProxyPort = proxyPort } ));