Sunday 2 August 2015

Cannot ping MetaTrader Trading Server - ping n/a

The Problem 
Having come across the dreaded "n/a" when attempting to ping a trading server; I found myself getting somewhat frustrated to say the least that i could not connect.

I had set up a fresh instance of an Amazon AWS Windows 2012 Server to use as a VPS. I then proceeded to install a fresh copy of MetaTrader 5 from MIG Bank / Swiss Quotes. The installation was complete and i was ready to use an existing demo account to login with.

Thats when the problems started. I clicked File > Login to trading account. And the terminal was just hanging, with the dreaded n/a shown in the ping column. This is a problem i saw ages ago with MetaTrader 4. In my wisdom, i thought i'd simply create a new demo account from File > Open an Account

Knowing the "Open an Account" dialog would allow me to (force) ping the sever in question, thus getting me back on track - Wrong! I was faced with the same issue again - n/a - aggghhhh !

Having ensured the firewall was allowing the MetaTrader application access to the network i was again left wondering why on earth i could not connect. Using the default server name i thought i'd be clever and enter that same address in to the field "Add a new broker like 'BrokerName' or address mt.company.com:443" - This achieved the same result - nothing.

More head scratching followed; and with that niggling feeling that a port was being blocked. I checked the settings in the AWS console. In particular "EC2 Dashboard" > "Security Groups" and selected the web server security group that i had previously setup. This was allowing http on port 80 both incoming and outgoing, all good, what now?

The Solution
Thats when a moment of clarity hit me that the trading server wants to "talk" over port 443... ah ha. So i proceeded to setup a "custom tcp rule" (in AWS console > EC2 > Security Groups) and specified port 443 for incoming and outgoing traffic.

Upon returning to MetaTrader 5, i again clicked File > Open an Account and sure enough the dialog showed the ping at 45.49ms which then allowed me to proceed with setting up an account.

I know metaquotes have browsed my blog before, so if you are reading this, then maybe another "if else" is required in the code to trap if the MetaTrader application cannot connect via port 443?
That'd be quite useful.

Aparently "The answer to the ultimate question of life, the universe and everything is 42" - In this case it the answer was port 443 ! 

Anyway, i hope this info may help others stuck in the same position.

Provider Info:
Amazon AWS - https://aws.amazon.com/ec2/
MetaQuotes MetaTrader 5 - http://www.metaquotes.net/
Broker: MIG Bank / Swiss Quotes  - http://www.swissquote.ch