Unity TCP socket connection not working on Mac OS X - macos

I'm trying to publish my Unity multiplayer game to Mac App Store, but by some reason in production the socket fails to connect to server, throwing the following exception:
"Access denied System.Net.Sockets.Socket.Bind".
I have "com.apple.security.network.client" and "com.apple.security.app-sandbox" entitlement, but it does not work. HTTP requests work OK though.
If I test the app in debug build - it works..what could be blocking it ? The port I'm using is 16005
This is the client connection code:
var tcpClient = new TcpClient();
tcpClient.Connect(Host, Port);
networkStream = tcpClient.GetStream();
listenThread = new Thread(ListenToServer);
listenThread.Start();
Any ideas ?

I Solved the problem.
It turns out I had to add the server entitlement too.
(Although I'm not starting any server nor listening for incoming connections).
So adding "com.apple.security.network.server" entitlement solved the problem

Related

How to deploy and interact with a rust websocket?

I'm a beginner in Rust and WebSockets and I'm trying to deploy on Heroku a little chat backend I wrote (everything works on localhost). The build went well and I can see the app is running, and I'm now trying to connect to the WebSocket from a local HTML/Javascript frontend, but it is not working.
Here is my code creating the WebSocket on my rust server on Heroku (using the tungstenite WebSocket crate):
async fn main() -> Result<(), IoError> {
let port = env::var("PORT").unwrap_or_else(|_| "8080".to_string());
let addr = format!("0.0.0.0:{}", port);
// Create the event loop and TCP listener we'll accept connections on.
let try_socket = TcpListener::bind(&addr).await;
let listener = try_socket.expect("Failed to bind");
println!("Listening on: {}", addr);
and here is the code in my Javascript file that tries to connect to that WebSocket:
var ws = new WebSocket("wss://https://myappname.herokuapp.com/");
My web client gets the following error in the console:
WebSocket connection to 'wss://https//rocky-wave-51234.herokuapp.com/' failed
I searched to find the answer to my issue but unfortunately didn't find a fix so far. I've found hints that I might have to create an HTTP server first in my backend and then upgrade it to a WebSocket, but I can't find a resource on how to do that and don't even know if this is in fact the answer to my problem. Help would be greatly appreciated, thanks!
I think your mistake is the URL you use:
"wss://https://myappname.herokuapp.com/"
A URL usually starts with <protocol>://. The relevant protocols here are:
http - unencrypted hypertext
https - encrypted hypertext
ws - unencrypted websocket
wss - encrypted websocket
So if your URL is an encrypted websocket, it should start only with wss://, a connection cannot have multiple protocols at once:
"wss://myappname.herokuapp.com/"

Unable to connect to feedback.sandbox.apple.com via tcp client in pushsharp

Unable to connect to the feedback.sandbox.push.apple.com with port number 2196.
Opened the ports (5223, 2915, 2916, 443) in windows firewall with TCP/SSL.
Tried connecting via telnet too, but did not help.
Getting the below exception
Service Exception: PushSharp.Apple.ApplePushService -> System.Net.Sockets.Socket
Exception (0x80004005): A connection attempt failed because the connected party
did not properly respond after a period of`enter code here` time, or established connection faile
d because connected host has failed to respond 17.172.232.45:2196
at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
at PushSharp.Apple.FeedbackService.Run(ApplePushChannelSettings settings, Can
cellationToken cancelToken) in d:\Sample Apps\Push Notification\PushSharp-master
\PushSharp-master\PushSharp.Apple\FeedbackService.cs:line 60
at PushSharp.Apple.ApplePushService.<>c__DisplayClass4.<.ctor>b__1(Object sta
te) in d:\Sample Apps\Push Notification\PushSharp-master\PushSharp-master\PushSh
arp.Apple\ApplePushService.cs:line 51
Failure: PushSharp.Apple.ApplePushService -> The maximum number of Send attempts
to send the notification was reached! -> {"aps":{"alert":"Hello World!","badge"
:7,"sound":"sound.caf"}}
Also, this does not need certificate to connect to sandbox, so why this exception?
You do need a development certificate from the Apple Developer portal to connect to sandbox. But I don't know if you need to use it to connect to feedback.sandbox.apple.
I can't seem to find a straight answer on this whether feedback services still works. I think APNS Feedback services are now deprecated. This could be why you're getting this error.
Does APNS Feedback service no longer exist as per new APIs?
APNS Feedback Service - is it still alive?

Genymotion androvm web service error Cannot connect java.net.ConnectException

I developed a simple application, calls currency converter webservice from www.webservicex.net. and deployed it on GenyMotion AndroVM.
But I am getting below error,
"Cannot connect to www.webservicex.net on port 80:
java.net.ConnectException: Connection timed out"
We have proxy and I defined proxy settings as well. I am able to access internet using browser inside AndroVM.
Please help
In Android, the system's proxy settings is not applied to all Http requests you made inside your app. It is applied natively inside the browser only that's the reason why you can use it.
Each application has to handle it "manually".
My first and quick advise is to use OkHttp as Http client because it handles it for you.
Or you can get the values manually and configure yourself your requests like this (gathered from here):
String host = System.getProperty("http.proxyHost");
String port = System.getProperty("http.proxyPort");
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpHost proxy = new HttpHost(host, Integer.parseInt(port));
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

Uploading file to FTP with VB.NET

I'm getting errors when trying to upload a file to FTP Server with the next VB.NET code:
Dim miUri As String = "ftp://ftp.mydomain.com/folder/file.jpg"
Dim miRequest As Net.FtpWebRequest = Net.WebRequest.Create(miUri)
miRequest.Credentials = New Net.NetworkCredential("user", "pass")
miRequest.Method = Net.WebRequestMethods.Ftp.UploadFile
Try
Dim bFile() As Byte = System.IO.File.ReadAllBytes("C:\carpeta\fichero.jpg")
Dim miStream As System.IO.Stream = miRequest.GetRequestStream()
miStream.Write(bFile, 0, bFile.Length)
miStream.Close()
miStream.Dispose()
Catch ex As Exception
Throw New Exception(ex.Message & ". El Archivo no pudo ser enviado.")
End Try
ex.Message = "Error on remote server: 227 Entering Passive Mode
(x,x,x,x,21,183). ." ex.InnerException.Message = System.Net.Sockets.SocketException = {"A socket operation was attempted to an unreachable network x.x.x.x:5557"}
The line of code that throws the exception is:
Dim miStream As System.IO.Stream = miRequest.GetRequestStream()
POINTS:
If I try to connect by FileZilla or other FTP Client, I can connect without problems.
If I disable the antivirus, I can connect without problems.
Before somebody says something related to the firewall...
IF THE ANTIVIRUS IS ON, AND I CONNECT BY FILEZILLA, I CAN CONNECT WITHOUT PROBLEMS.
¿Where is the problem? ¿What I have to do in my code to get it run with the antivirus ON?
If FileZilla can, I also have to be able...
Thanks a lot for your replies.
Regards,
Sorry for the issue.
Finally it was because of the antivirus version I had installed.
Even putting the application as a trusted application, antivirus continued blocking the application.
I installed another version of the same antivirus and everything works fine.
Regards.
"A socket operation was attempted to an unreachable network x.x.x.x:5557"
means that the server could not be reached. There are a number of reasons that could cause this issue.
The server is down.
Your computer is blocking the server connection incoming / outgoing
(firewall)
Unreliable internet access
You mis-configured your connection string (the server string)
Essentially the issue most users will experience is that their firewall is blocking access to their FTP connection request. To fix this you must allow the application through your file wall.
-Cheers

Other hosts cannot connect to websocket server on my host

First of all, sorry for my bad English : )
My Java application (multiplayer game server) uses this package to communicate with a web application in client's browser using websockets: https://github.com/TooTallNate/Java-WebSocket
I've encountered a problem running my application: only I can connect to the websocket server, clients on other hosts can't do so. In browser I estabilish connection as usual, address here is certainly correct:
new WebSocket("ws://"+serverIp+":8787");
When I connect from my own host to the websocket server running on the same host, it runs perfectly. When other hosts try to connect to me, connection in not being estabilished: in browser WebSocket objects's .readyState is 0 (whilst it should be 1), and even server does not recieve any handshakes (no output from onClientOpen in server console, I even tried to get any output from certain WebSocketServer class' methods).
Other hosts are still recieving, for example, static contents of web application from webserver on 80 port on the same host. Problem is not the closed 8787 port: I checked it, it's open.
What may be the reason that other host can't connect to my websocket server?
WebSockets uses a cross-origin permission system. You might need to tell you WebSocket server to accept connections from more than just your local host. The verification of Origin happens during the WebSocket handshake which likely happens prior to onclientOpen.

Resources