Need assistance with TCP Reverse connection - vb.net

I am creating an authentication server for some projects I'm working on. This authentication server works by receiving and transmitting data to users trying to authenticate. The user can send data to the server succesfully but when sending back it requires port forwarding. I read a way that I would not require port forwarding by using reverse connection but I have no idea how to get it working. I found a tutorial and tried to implement but when it tries to connect to read the stream it says the connection is refused.
Any ideas?

If the user is already connecting to the server, why not just keep the (existing) connection open, and use that for bidirectional communication?
I can see no reason to open a second connection from the server back to the client.

Related

VB.NET Server Does Not Receive Connection Requests from Remote Clients

VB.NET Server Does Not Receive Connection Requests from Remote Clients
A VB.NET server application does not see connection requests from another client on the network (i.e. with a different IP address). However, it does see connection requests from the client application running on the same computer as the server.
The listening socket is created with the following parameters
System.Net.Sockets.AddressFamily.InterNetwork
System.Net.Sockets.SocketType.Stream
System.Net.Sockets.ProtocolType.IP
We have experimented with the preceding without success.
The endpoint to which the listening socket is bound specifies the local IP address and a specific port number.
The wait-for-connection code is textbook asynchronous:
thelistener.Listen(10)
thelistener.BeginAccept(New System.AsyncCallback(AddressOf targetofaccept), thelistener)
If the client that attempts connection is on the same computer as the listener, then targetofaccept is run successfully. If the client that attempts connection is on some other computer on the network, then targetofaccept is not run.
The behavior occurs for any other client on the network (i.e., not just one).
Thinking that there was some firewall issue, we created VB6 servers and clients using the same addresses and ports. The VB6 server will receive connection requests regardless of the client system.
There is no other issue with communication between clients and the server, as far as we can see. The network architecture has not been modified for a number of years.
We are debugging the code as a VB.NET console application.
Any tips on how to diagnose appreciated.
Before calling Listen() you need to bind your listener socket to the address 0.0.0.0 (in .NET IPAddress.Any) so that it listens to connections from any IP address.
This can be done using the Socket.Bind() method:
Dim listenerEndpoint As New IPEndPoint(IPAddress.Any, <your port>)
thelistener.Bind(listenerEndpoint)
thelistener.Listen(10)
Thank you.
Issue WAS firewall. Fixed by finding exact location of the IDE (devenv.exe), opening "Windows Firewall" in the control panel, selecting "Allow a program or feature through firewall", selecting "Allow another program...", browsing to the exact location and selecting the executable, then ensuring "Home/Work (Private)" column is checked for that "Name".

FTPS client procedure for data connection

I am developping a FTPS client in a Embedded system with LWIP and mbedTLS stacks.
For now, what I do is :
Get an IP adress with DHCP
Get IP address of the server with DNS
Start a TCP connection to the server ( the control connection)
Telling the FTP server that I want to work with the TLS protocol with the command AUTH TLS
Handshake of the TLS protocol with the server
Validate the x509 certificate that the server sends
Telling the client that I want to work in passive mode and that i want to read a file with the command RETR.
Now, I need to open a data connection to read my file. So what I wanted to know is does the data connection is secured in the same way the control connection is ? That means do I have a certificate to validate ? Is the handshake the same ?
If this isn't clear let me know i'm not an expert at all in this area.
Thank you for your future responses
In explicit FTPS connection after you send AUTH command, the data connection is secured all the way. Depending on Active/Passive connection the data connection is opened through port 20(Active) or some random port negotiated(Passive).
You don't need any extra handshakes as far as I know.
You might or might not be able to configure if you want to reuse the same session ID created in opening the control channel. This is related for server to know that data connection has been established by the same client which opened the control channel. Some server require this, some servers allow this, some servers does not support this.

Notepad++ and SFTP connection issue

I am trying to connect to SFTP server using notepad++ plugin NppFTP. However, while connecting to the remote server I always get below error:
Connecting
[SFTP] Connection failed : Timeout connecting to <IP address>
Unable to connect
Disconnected
Here are the important configuration details set in NppFTP window for your reference:
Port: 22
Connection Type: SFTP
Authentication: Try password authentication
I tried to go through some of the solutions stated in few the questions in Stack Overflow but to no avail.
Would really appreciate your suggestions/pointers to resolve this. If it is related to SSH private key, would appreciate if you can provide the steps as well.
Edit: I am able to access the server using another FTP tool FileZilla which eliminates any mess with the access front.
You need to find out more about where the issue is:
Can you ping the server you are trying to connect to?
ping 166.178.233.70
Did you try connecting with another ftp tool, like FileZilla, that gives more detailed log information?
The possible issues are numerous:
The ftp server config: set up to exclude connections from certain ip addresses or domains, requires public/private keys...
Your local connection/VPN is not passing the connection.
It may require a
I got the same issue. The problem was solved after I updated NppFTP.
in my case, I changed the wifi connection then, it works.

Cannot establish a connection to SQL Server over VPN using TCP protocol

During my daily work, I need to use the customer's Database. for this connection, first of all, I need to connect the VPN to customer's network, and then make the DB connection.
Normally, if this connection can be established using TCP protocol. But sometimes I cannot connect to the DB. Then I track the network package, I found the connection is attempting connect to customer's DB using UDP protocol.
And now my network environment is using '172.16', if I change my network to '10.12', do the same connection, then change back to the '172.16' network, the connection can be established successfully.
Because the DB is in customer's side, I cannot check it.
The first couple of things I'd look at:
Firewall
... and ...
Firewall
PS:
Yesterday I had a case where the customer's database could communicate by Windows host name or by "localhost" ... but NOT by IP, nor by hostname alias ... even though the client and the SQL Server were ON THE SAME PC!!!!
Windows firewall was OFF. There wasn't any router between SQL server and the client (remember: same PC!).
But they installed a new A/V program ... that had it's own firewall ... and wouldn't allow any SQL Server connections.
PPS:
The correct approach, of course, is to configure firewall exceptions for all services you need (like MSSQL).
You could check with the customer's server administrator if the VPN access you have would have sufficient port/route access with customer's server database.
Normally VPN access allow outsider to gain access to internal network but it might be assigned by different router at the time you encountered problem. It isn't db problem, it is network issue.

Identify connection lost between Socket Server and Socket Client in VB.Net

Friends,
I wrote a Socket Client which will send the Socket Server some data and get some response from Server. This process will be running once in every 2 seconds.
Now what I need to know is How we can identify the connection lost between Server and Client?
I need this to be implemented in the Client side. If there is no connection then Client should automatically close the connection. Once the connection with the server is available in the next attempt it should connect automatically.
Thanks in advance!
I'm not a vb.net developer, but this is how it works in most languages.
Writing to a lost/closed connection will fail, the client will then know that he needs to reconnect.
It's never possible to know if a connect attemt to a server will succedd before you have done it, so your client should try to reconnect in a loop with a sleep/wait period in between each connection attempt.