good day. i have a project whit arduino mega 2560 and ethernet shield w5100 whit the library ethernet.h. The problem is:. when try to open the port 5060 and try to access from any device to this port, no efect but no errors apear. if change the port 5060 by other port (example 5059), the program run correctly. In no case do compilation errors appear
please, Does anyone have any idea where the problem might be ?
thanks.
That isn't really enough information. What type of port is it? TCP, UDP, something else?
Perhaps port 5060 is being blocked somewhere, e.g. firewall on windows PC. Again not enough information to do anything other than guess.
It would be helpful if you posted your mega2560 code (in code tags ideally), and a description and / or diagram of how you are using some other device to access the port you opened on the mega2560
Thank you for your reply.
No, port 5060 is not blocked on my network. In fact, other devices use this port without any problem.
This is my code.
#include <Ethernet.h>
//********** NETWORK PARAMETERS *********
byte ip[] = {192, 168, 0, 50 }; // Server IP Address
byte gateway[] = {192, 168, 0, 1 }; // Gateway IP Address
byte subnet[] = {255, 255, 255, 0 }; // Subnet Mask
byte mac[] = {0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6 }; // Server MAC Address
EthernetServer server = EthernetServer(5060); // Server Port (NOTE 5060 don't run,
// 5059 run ok)
char c;
//********** START SETUP *********
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
}
//********** END SETUP *********
//********** START LOOP *********
void loop()
{
EthernetClient client = server.available();
if (client)
{
boolean currentLineIsBlank = true;
boolean sentHeader = false;
while (client.connected())
{
if (client.available())
{
char c = client.read();
Serial.print(c); // Here each character received is printed
}
}
}
}
//********** END LOOP *********
As you can see, it is very simple.Texto preformateado
Let me check I've understood correctly. I think you are:
- Creating a TCP server on the 2560 which listens on port 5060.
- Connecting to that server from some client.
- When it works the 2560 copies characters received from the client to Serial.
- It doesn't work when the server port is 5060, but it does work with other port numbers.
I can't think why it doesn't work with just port 5060. What is the client? If it's a PC perhaps you could use WireShark to capture what is happening on Ethernet at the client end.
If something else connected to it first then that would block further connections. When you try and connect from your client does the connect fail? Perhaps add a Serial.println("Client connected") where I put the red arrow.
Oh yes, I already inserted Serial.print on many lines but no actions appear. I think the ethernet.h library does not enable the use of port 5060 because this port is used for SIP purposes, exactly the usage I need. The strange thing is that it does not report any compilation errors.
You could check that if you get a wireshark capture of the client trying to connect.
Hello Dave. I found some information about using the 5060 port on the Arduino Ethernet. As I expected, this port is reserved and Arduino does not allow its use. Unfortunately, I cannot use another port because the devices that need to contact it have this fixed port and it cannot be changed.
Thank you very much for your time.
I don't know exactly which Ethernet library you are using. For a lot of libraries I've looked into the source is on GitHub. Maybe you could modify the library to not block that port. I did look at one Arduino Ethernet library in GitHub yesterday, and searched for 5060, but didn't get any hits.
This is not correct. You have the gateway set to 255.255.255.0
Ethernet.begin(mac, ip, gateway, subnet);
It should be
Ethernet.begin(mac, ip, gateway, gateway, subnet);
Hi SurferTim.
Sorry, I don't understand. Are you saying that gateway must be repeated twice?
Yes, @SurferTim is correct..
consider..
static void begin(uint8_t *mac, IPAddress ip);
static void begin(uint8_t *mac, IPAddress ip, IPAddress dns);
static void begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway);
static void begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet);
using the gateway twice, first one is dns, second is gateway, should work..
there's no block on port 5060 that I have found either, so something else is buggering you up..
good luck.. ~q
I'll bet it's your web browser blocking the request. Port 5060 on Linux is for SIP. Firefox knows it and won't connect.
I can connect using a nmap port scan without ping. My ethernet shield is 192.168.1.7. Server on port 5060.
nmap -v -sV -Pn 192.168.1.7 -p 5060
Thank you very much, I will continue investigating to see if I can solve it,
If you aren't planning on using a web browser, it may not affect the connection. NMAP had no problem getting my error page on port 5060. The Mega2560 serial output showed the attempt.