4.7.3 tcp ports not closing

Hi there,

In previous versions 4.6 and below when the connection to ports were closed in code. E.g when an actor is destroyed the port could then be reused by the same actor in a different level for example. However in 4.7 this now no longer works. The ports when using .Close() in code seems now not to close the connection.

Has anyone else had this problem had this problem?

Something very similar has been reported here.

Regards,

Peter

Hey -

Could you elaborate on your issue for me? What ports are you referring to? How are you using Close()? Could you provide an example of what you’re seeing or steps to follow to reproduce this on our end?

Cheers

Thanks for the reply.

I have some custom C++ plugin, which acts as a TCP receiver attached to an actor. A TCP blueprint derived from the plugin is created which (for the sake of example) prints received data from a selected port and address. On each level blueprint a TCP initializer box is run on level startup. What should happen is that the tcp connection is destroyed when changing maps this would free up the port.

Now the plugin’s creator has told me that in previous versions of UE4 the plugin has worked perfectly.

For example, with the previous set up; I have an external program, which pipes data to UE4 on a set address and port. When I play a level data is printed which is what I expect. However when I change map I would expect the same behavior to happen, data being printed. However this isn’t the case.

Below is the EndPlay method of the plugin:

void ATCPReceiver::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
	Super::EndPlay(EndPlayReason);
	//~~~~~~~~~~~~~~~~
	
	//Clear all sockets!
	//		makes sure repeat plays in Editor doesn’t hold on to old sockets!
	if(ListenerSocket)
	{
		ListenerSocket->Close();
		ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(ListenerSocket);
	}
	if(ConnectionSocket)
	{
		ConnectionSocket->Close();
		ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(ConnectionSocket);
	}	
}

I have confirmed that this code is being executed by printing log messages before and after the close lines. So I am confident that this method is being executed.

This problem with the close method not working is also highlighted here

I have tried in the above link the solution of using reusable sockets but this doesn’t solve the problem.

If you require any more information please give me a shout, would be good to solve this.

Peter

I have emailed the plugin’s creator to ask exactly which version of UE4 the plugin works perfectly as should do mentioned above but I have looked on GitHub at previous versions Close() methods in the engine and I can’t see much of a difference from previous version and 4.7.3.

Hi ,

What is the plugin that you are using for this?

Its actually a plugin from , he has tested it and confirmed that the plugin no longer works properly in 4.7.

Hi ,

Unfortunately we are not able to provide support for plugins created by another user. If is able to update his plugin to work with 4.7, it should also resolve the issue you are experiencing. If you continue to have trouble after the plugin is updated, we can try to find out what is happening (if it is something happening between the Engine and the plugin, may need to get in touch with us to resolve it).

I will mark this post as resolved for now, but it can be re-opened later if necessary.

#Solution

Following this work flow I was able to reopen socket after changing levels:

  1. start first level
  2. start python script
  3. observe the onscreen msgs
  4. open console, open new level (this closes first socket and opens new one)
  5. reactivate the python script //<~~~~~

I did not do step 5 in my initial tests, it seems that when the UE4 socket closes, the Python script gets stopped too!

I was not expecting the python script to close when the ue4 socket closed, so that is why I did not resolve this sooner.

Now I know I have to restart the python script if the UE4 socket connection gets closed :slight_smile:

Thank you for UE4 Epic!

#:heart: