简体   繁体   中英

Windows service TCP communication in local network

I've been trying to set up a service that runs in the background and communicates with a Server via TCP. I'm using the .NET Core to set up a TCPListener and, on another device, try to remotely connect via a TCPClient. If i use this outside of a service, in a user executed programm, it works just fine. However, if i start my service, the port im listening to only receives messages from 127.0.0.1, not from the local network.

I suspect there's some permission the service needs to accept network communication, but this is not really my field of expertise. Any advice?

There's no error message. Using Wireshark i confirmed that theres an incoming TCP request on the host, but no connection gets established with my Service.

Thanks in advance o/)

Edit: I found out that it works if i disable the public firewall on the host PC. But im not really proficient with reading and interpreting the logs. the relevant sections read as follows:

Firewall Log output

Fields: date time action protocol src-ip dst-ip src-port dst-port size tcpflags tcpsyn tcpack tcpwin icmptype icmpcode info path
                                                                                                                                                                                                2019-08-29 15:43:58 DROP UDP 192.168.7.98 192.168.7.255 34638 15600 63 - - - - - - - RECEIVE
2019-08-29 15:44:01 ALLOW UDP 192.168.7.117 192.168.7.70 137 137 0 - - - - - - - SEND
2019-08-29 15:44:02 DROP TCP 192.168.7.46 192.168.7.117 49958 13000 52 S 1580866692 0 64240 - - - RECEIVE
2019-08-29 15:44:03 DROP UDP 192.168.7.62 192.168.7.255 57621 57621 72 - - - - - - - RECEIVE
2019-08-29 15:44:04 DROP UDP 192.168.7.98 192.168.7.255 54123 15600 63 - - - - - - - RECEIVE
2019-08-29 15:44:05 DROP TCP 192.168.7.46 192.168.7.117 49958 13000 52 S 1580866692 0 64240 - - - RECEIVE
2019-08-29 15:44:10 DROP UDP 192.168.7.98 192.168.7.255 58249 15600 63 - - - - - - - RECEIVE
2019-08-29 15:44:11 DROP TCP 192.168.7.46 192.168.7.117 49958 13000 52 S 1580866692 0 64240 - - - RECEIVE

(Important are the dropped packages with destination 192.168.7.117:13000.) Does anyone have an idea of how to read those and find out why it's blocking it, and how to stop it from doing so?

Update:

The problem was the public firewall blocking service communication for that port. Easiely fixed by adding a two rules that allowed my windows service to communicate with the assigned port number.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM