Community discussions

MikroTik App
 
jvzg545cr
just joined
Topic Author
Posts: 9
Joined: Tue Apr 17, 2018 11:02 pm

API external connection

Tue Apr 17, 2018 11:10 pm

Greetings community,

I'm trying to connect remotely with the api but I can not connect.

These are the connection data

Image

It's in Laravel.

Code: Select all

protected function connection()
{
if (Auth::check())
{
$id = Auth::user()->id;
$mikrotik = Mikrotik::where('user_id', $id)
->first();

try {
$this->client = new RouterOS\Client($mikrotik->ipaddress, $mikrotik->user, $mikrotik->pass,$mikrotik->port);
} catch (\Exception $e) {
print "Error connecting to RouterOS";
}
}else{
echo 'no logeed';
}

}
.

Excuse my English, I am the translator.
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: API external connection

Wed Apr 18, 2018 9:40 pm

You probably need to enable PHP to make outgoing connections in the web server's firewall.

If you're on a web hosting plan, chances are you can already make outgoing connections to port 80 (HTTP), 443 (HTTPS) and 23 (FTP). Try to change the API port to this one, and connect with that instead. If it works, that's certainly the cause, and you only need to add 8728 to the whitelist if you need to use those ports too.

Who is online

Users browsing this forum: No registered users and 67 guests