Metatrader 5 Python Socket/Websocket communication 4014 error - sockets

I am trying to create a communication interface between a python socket server and a Metatrader 5 Expert Advisor.
I've tried multiple approaches and tutorial's I found online for both sockets and websockets. All of these approaches yield the same problem.
Whenever I start a debug on live/historical data, I get a Socket creation error with code 4014. According to the error codes it is a "Function is not allowed for call" error.
Multiple sources recommended to allow web request from specified URL's. Ive done this as well for 127.0.0.1 and localhost. (Tools > options > Expert Advisors)
Why am I getting a function not allowed for call error, and how can this be fixed?
Expert code:
int socket=SocketCreate();
int OnInit()
{
if(SocketConnect(socket,"127.0.0.1",9090,1000))
{
Print("Connected to "," 127.0.0.1",":",9090);
}
else
{
Print(GetLastError());
}
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
SocketClose(socket);
}
void OnTick()
{
SocketClose(socket);
}

We had similar issue in the past and was resolved it by adding the hostname/IP to connect to to the list of allowed URLs in Tools->Options->Expert Advisor.
You can also use a MetaApi service to communicate with MetaTrader via developer-friendly SDKs and code your expert advisor in Javascript, Java or Python.
Hope this is useful to some degree.

I faced the same problem.
Works for me: to point exactly '127.0.0.1' (without upper commas) in address input field.
Also, check your firewall settings - it may block your ports.
The best regards.

Related

Using MQL5 network functions on strategy tester

I want to receive data from metatrader and use them to do some process in another programming language, i can connect metatrader and my other script code with the network functions that mql5 has been provided but they don't work for testing on strategy tester panel
is there any way to gain a permission or bypass that problem?
everything works fine when i add the expert to charts but for backtesting not work and when i want to create socket using CreateSocket function return a permission error (4014)
int socket = CreateSocket()
if(socket!=INVALID_HANDLE) {
Print("Failed to create a socket, error ",GetLastError()); // return 4014 on backtesting
}
is there any way to allow metatrader to use network functions here?

MQTT connection creation and subscribe

I'm setting up a new mqtt conection in my app but there is a problem when i would like to create the main connection of mqtt.
I'm using mqtt.js.
I've tried all what is done in MQTT documentation but nothing happens..
mqttFunction(){
var mqtt = require('mqtt');
var client = mqtt.connect([{host: 'localhost', port: '1883'},]);
client.subscribe('presence')
client.on('message', function (topic, message) {
console.log(message);
});
}
I expect the output of the mqtt broker to be 'ON' when i asked it to respond.
The error is: ERROR ReferenceError: process is not defined
The documentation you followed is intended for Node.js and various other back-end JavaScript frameworks. Even though it uses NPM, Ionic ultimately produces a front-end framework, and its applications run a bit differently.
For example, Ionic programs may not have a global process variable like Node.js. mqtt.js expects this variable, with code like:
if (commist.parse(process.argv.slice(2)) !== null){...}
You could declare a process object, and get past this particular error. Other obstacles could come up.
var process = {env : {NODE_ENV: 'production'}}
If there are still issues with that, you could try the instructions for browser usage, which point to a specially compiled version, like https://unpkg.com/mqtt#3.0.0/dist/mqtt.min.js. I have had less luck with mqtt.js in the browser, and you may want an alternative like web-mqtt-cient / Paho if more complex connections are involved.

Internet Control Message Protocol for Java

Pls help me guys. I end my work for one simple program. I need to check a servers status. I tried to use InetAdress.isReacheble and Socket. But sometimes if server on windows I get a server status false. After reading a lot of information, I realized that this is one of the bug of java enter link description here. But the sources are old. Is this problem still relevant?
I tried using code this comment enter link description here
private static boolean isReachable(String addr, int openPort, int timeOutMillis) {
try {
// Any Open port on other machine
// openPort = 22 - ssh, 80 or 443 - webserver, 25 - mailserver etc.
try (Socket soc = new Socket()) {
soc.connect(new InetSocketAddress(addr, openPort), timeOutMillis);
}
return true;
} catch (IOException ex) {
return false;
}
If server on Windows I use port RDP (3389).
But the customer does not like. He wants me to check the status through ICMP. Is this possible?
I found the app ICMP enter link description here. Tried to connect from the application library but nothing happened.
I will be grateful for any information!
InetAddress.isReacheble by default uses icmp enter link description here
Pls sorry for my stupid question

Sammy.js working fine one localhost but not when calling from remote computer

I'm working one SPA with sammy.js and jquery.tmpl.
It's kind of huge project what the company want to work as an SPA.
The issue is that there are few different states for the app (used to be three different pages and now it is all in one, add, edit and add for a non registered client).
When i am developing from my own station (IIS6.1 for windows 7, not VS IIS) and using both localhost of my IP address every thing is working great, but when trying to connect with a domain name (changes the host in my station) or from a remote computer both with ip or domain name i'm getting an 404 from sammy:
body 404 Not Found get /employer/newemployers/index.aspx#/edit/2354478 Error {message: "404 Not Found get /employer/newemployers/index.aspx#/edit/2354478 ", stack: "Error↵ at Object.n.Application.e.extend.error (…oyers/javascript/lib/jquery-1.7.2.min.js:3:17273)"} sammy-0.7.4.min.js:8
My Sammy.js code:
$.sammy('body', function () {
this.get('#/', index);
this.get('#/index', index); //For Non registered Employer
this.get('#/indexPageAdd', indexPageAdd); //For Registered Employer
this.get('#/Edit/:JobID', MainEdit); // For Job Edit
this.get('#/firstStage', firstStage);
this.get('#/secondStage', secondStage);
this.get('#/thirdStage', thirdStage);
}).run('#');
Any one encountered this type or issue? Couldn't find this anywhere..
Thank you
Found the answer,
When calling from my own computer( localhost or ip), Sammy.js is case insensitive, but when trying to use real urls (on my own computer or from remote computer) need to use case sensitive urls, the edit is with capital E and i used lowercase e and didn't notice.... added a record for lowercase and every thing is working great now.
Hope this helped anyone with the same problem

Knowing from which udp socket the Radius request came. Using FreeRadius

I know the question isn't very well. Sorry my english.
I want to setup a (one instance of) FreeRadius server to listen to several ports (with a bunch of 'listen' sections) and then pass the that udp port as a parameter along with User-Name and User-Password to a script that I want to use to make the authentication.
The basic idea is make some kind of domain separation. Some Firewall use radius port 2000 to make authentication. Some other different firewall (with a different set of users) use radius port 2020, for example. At the end, all the request fall in the same script that has the knowledge of both set of users and use one or the other according to the given extra attribute (port number)
I know that is possible making a virtual server per 'domain'. but I prefer not to replicate configuration files. and i think is shorter to add a little 'listen' section for every domain I want.
I tried to add an atribute this way:
listen {
ipaddr = *
port = 0
type = auth
update control {
Login-TCP-Port = 1812
}
}
and tried to read it:
autorize {
if ("%{User-Name}" == "bob") {
update reply {
Reply-Message = "This is only %{Login-TCP-Port} an example."
}
update control {
Cleartext-Password := "bob"
}
ok
}
[...]
}
But don't work.
How can i make it right?
Is this posible?
Hope you can help me.
I'm answering myself. I found (looking a like further on google) that the Packet-Dst-Port attribute have the data that I want.
I get it from here (now that I found it, look pretty obvious :P)