I have an issue when connect to Realm Object Server on my device but it works on simulator.
it's return errors :
Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server."
UserInfo={NSUnderlyingError=0x170255450 {Error
Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo=
{_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}},
NSErrorFailingURLStringKey=http://127.0.0.1:9080/auth,
NSErrorFailingURLKey=http://127.0.0.1:9080/auth, _kCFStreamErrorDomainKey=1,
_kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the
server.}): file
/Users/tungvu/Desktop/Swift3Xcode8/RealmTask/RealmTask/ViewController.swift,
line 57
Here's my connect to Realm Object Server function:
SyncUser.logIn(with: .usernamePassword(username: username, password: password, register: false), server: URL(string : "http://127.0.0.1:9080")!) { (user, error) in
guard let user = user else {
fatalError(String(describing: error))
}
DispatchQueue.main.async {
// Open Realm
let configuration = Realm.Configuration(
syncConfiguration: SyncConfiguration(user: user, realmURL: URL(string: "realm://127.0.0.1:9080/~/realmtasks")!)
)
From the looks of it, you're using the localhost IP address 127.0.0.1. While this will work with apps running on the same device as the Realm Object Server instance (ie the iOS Simulator), you'll need the actual IP address of the machine on the local network in order to connect from a separate device like an iPhone.
The easiest way to find the network IP address is to hold down Alt, and then click on the Wi-Fi icon in the macOS status bar:
If you replace 127.0.0.1 with your Mac's network IP address, other devices should then be able to connect to it. This should work for the iOS Simulator as well, so there shouldn't be a need to change it until your machine's IP address changes.
Related
I got following crash report in firebase crashlytic. Even thought, I use Connectivity WrapperIt is still throw a lot. The country most of the user used in is blocking the ip. They only open for selected app. There are a lot of ISP and some are blocked our ip and some are not. For example, they blocked facebook. How can I check and tell the user need to open VPN to use this app.
SocketException: Failed host lookup: 'fileapi.domain.org' (OS
Error: No address associated with hostname, errno = 7). Error thrown
Instance of 'ErrorDescription'.
SocketException: Connection reset by
peer (OS Error: Connection reset by peer, errno = 104), address =
fileapi.domain.org, port = 36536.
SocketException: Software
caused connection abort (OS Error: Software caused connection abort,
errno = 103), address = fileapi.domain.org, port = 49644.
Connection closed before full header was received. HandshakeException:
Connection terminated during handshake.
I'm using the mysql1 package to connect to MariaDB.10 database using (MariaDB4j)
Issue:
1- it connects if I test the Flutter app on Windows but does not work if I test it on a real android phone.
I got this error:
I/flutter ( 3337): SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = 192.198.1.108, port = 53416
The code: port is 3306 as you can see above on the error message the port keeps changing, and I'm connecting the IP of the phone on the local network.
var settings = ConnectionSettings(
host: _host,
port: int.parse(_port),
user: 'root',
password: "",
db: 'distoresql');
conn = await MySqlConnection.connect(settings);
Note: I have added a user to the Mysql user with the phone IP and GRANT ALL PRIVILEGES to this user and IP, and I have disabled security on the connection.
I am getting this error in my debugger.
From what I understood it's an error generated by ip config.
I found this solve here, but i dont understand where should i modify it. where should i change the ip address?
Flutter SocketException (SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 51500)
ERROR - 2021-03-23 18:21:26.074284
PUT /SXUs66yGd7s=/
Error thrown by handler.
SocketException: OS Error: The remote computer refused the network connection.
, errno = 1225, address = 127.0.0.1, port = 59250
Help!
Thank you alot
I was going through this trouble myself
i just disconnect the emulator and restated
Not sure what is your environment:
for me->
I tried to run windows app with xampp localhost and received this error.
then i changed my uri in frontend to
String uri = 'http://127.0.0.1/db-name';
after that, all working.
in the emulator the uri is different.
String uri = 'http://your ip addres/db-name';
to get your ip address->
open cmd and run "ipconfig"
use ipv4.
We have similar servers on two types of hardware devices, which we need to connect to using iOS application. Currently we are using Alamofire 4.9.1 for all the API requests.
Previously we supported only http endpoints on our servers, but recently we have moved to https on latest version of the devices.The app needs to support both.
The issue that we are facing is, when we connect to a Device X(which supports https), and then try to connect to Device Y(which only support http), we are getting this error
[Error] GET 'http://172.30.1.1/file.xml' [27.7252 s]:
Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x281f2fde0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://172.30.1.1/file.xml, NSErrorFailingURLKey=https://172.30.1.1/file.xml, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}
Connecting to device Y(http) directly without first connecting to Device X(https) works fine, and after the error if we kill the app we are able to connect to Device Y(http). This happens even though we are using different SessionManagers in Alamofire.
Is this because we are using the same ip address? If we check the error NSErrorFailingURLStringKey, it is still https although the url we are calling is http.
I am pasting the relevant code here
private var manager: Alamofire.SessionManager = {
let configuration = URLSessionConfiguration.default
let manager = Alamofire.SessionManager(configuration: configuration)
manager.retrier = RetryHandler()
return manager
}()
private var manager2: Alamofire.SessionManager = {
var serverTrustPolicies: [String: ServerTrustPolicy] = [
"172.30.1.1": .disableEvaluation
]
let config = URLSessionConfiguration.ephemeral
//Adding TrustManager to Allow All Certificates
let manager = Alamofire.SessionManager(configuration: config, serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies))
manager.adapter = RequestInterceptor()
manager.retrier = RequestInterceptor()
return manager
}()
Things we have already tried :
Use different UrlSessionConfiguration
Set config.urlCache = nil
Here is the scenario:
I have multiple application servers running locally for now (should be running in different host) --> each is listening on different port (at localhost).
I have a single client application running on Tomcat.
When startup Tomcat, login with different user's details with connect to different (above) servers remotely.
My problem is:
First, I startup Tomcat and logged in as userA, it then connected successfully to serverA(localhost:1000).
Then I logged out.
Logged in again as userB, it did NOT connect to serverB(localhost:1001) as expected; instead, it gave exception
"javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown"
However, if I restart Tomcat, and login as userB first, it then connects successfully to serverB.
Does anyone know what the problem is?
I really appreciate any suggestion :)
Code for client Tomcat:
SetupClientKeystore();
SetupServerKeystore();
SSLContext context = SetupSSLContext();
SSLSocketFactory socketFactory = sslContext.getSocketFactory();
SSLSocket socket = (SSLSocket) socketFactory.createSocket(hostname, portNo);
GZIPOutputStream gZipOut = new GZIPOutputStream(socket.getOutputStream()); // no trust certificate found throws here
Code for serverA and B:
setupClientKeyStore();
setupServerKeystore();
setupSSLContext();
server = new ServerSocket(portNo);
SSLServerSocketFactory socketFactory = sslContext.getServerSocketFactory();
serverSocket = (SSLServerSocket) socketFactory.createServerSocket(portNo);
serverSocket.setNeedClientAuth(true);
while ( true )
{
Socket client = serverSocket.accept();
inStream = client.getInputStream();
BufferedInputStream bufferedIn = new BufferedInputStream(inStream); //unknown_certificate throws here
//do something here.....
}
"javax.net.ssl.SSLHandshakeException: Received fatal alert:
certificate_unknown"
This usually indicates that the server's certificate is not trusted.
Could it be that when you log-in as userA you load the trusted certificate of serverA and connect, and then when you try to connect to serverB you try to authenticate serverB using the certificate of ServerA (loaded when you logged in as userA)?
As a result the SSL handshake fails.
So when you restart and login as userB the appropriate certificate (i.e. of ServerB) is loaded and the connection is succesfull?
You have no code in your post but if you do it as I say, this explains the exception.