Trouble connecting to Realm Server on AWS EC2 - swift

I am having trouble connecting to my online Realm on EC2. I've got an EC2 instance running. I've run start-object-server.command. I've pasted the code for my setupRealm() method.
let address = "XX.YYY.ZZZ.AA:9080" // "IPv4 PublicIP" from my EC2 dashboard
var httpURL: URL! { return URL(string: "http://" + address)! }
var realmURL: URL! { return URL(string: "realm://" + address)! }
func setupRealm() {
// My credentials when setting up the Realm admin dashboard after launching realm object server.
let username = "XXXXX#gmail.com"
let password = "XXXX"
let credentials = SyncCredentials.usernamePassword(username: username, password: password)
SyncUser.logIn(with: credentials, server: httpURL) { user, error in
guard let user = user else {
print(String(describing: error!))
return
}
...
}
}
SyncUser.logIn produces this error:
Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server."
UserInfo={NSUnderlyingError=0x600000059680 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)"
UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}},
NSErrorFailingURLStringKey=http://XX.YYY.ZZZ.AA:9080/auth,
NSErrorFailingURLKey=http://XX.YYY.ZZZ.AA:9080/auth, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61,
NSLocalizedDescription=Could not connect to the server.}
I also can't log in to my synced realm using the Realm Browser, though I am able to open local (non-synced) realms from the iOS simulator. And I am running the latest version of Realm Browser.
What's strange is that a week or so ago I was able to connect to the EC2 realm using both my app and the browser, as well as another app that syncs with the realm. I've compared the code and they're basically the same –- any differences I've spotted I am very confident that they don't matter (and I've tried changing some things back, to no avail.)
Since the time it was working, I've installed the recent macOS updates, as well as the Realm 2.5 update. I had some trouble with the realm updates and wound up installing and reinstalling them a few times, but I believe it's working normally, with, again, the latest version of everything. I don't think I changed anything else, I don't remember.
Unfortunately, I actually don't remember my process for setting up the EC2 server -- that is:
I don't think I did anything with AMI's. I don't remember installing any, or anything like that. Although my EC2 instance does have an AMI ID: realm-object-server-hvm-20170309 (ami-d518b9c3). So maybe I did.
I have my keypair in a safe place on my HD, and I think I used it for something at some point...but I don't remember.
I think I used my Public DNS for something at some point...but I don't remember.
What I do remember is:
I didn't use CocoaPods for anything. I dragged in the Realm frameworks and did import RealmSwift (though I have since installed and used CocoaPods for other things and would be fine converting these projects to use CocoaPods)
In the instructions to install Realm Object Server the only thing I did was install the macOS bundle and run start-object-server.command to start the server. I didn't do anything past that. No configuration or security groups or anything. I didn't do any of these because I'm a relative beginner and I don't understand most, if any of it (doing very well with swift but all this terminal code and server stuff is generally over my head). For instance, I don't really understand any of the "Mandatory settings" section, like how to specify settings in the config file, or how to give them as command line arguments.
Similarly, I'm unclear when it's necessary to have the server running in the terminal. I only just realized today that the reason that localhost:9080 sometimes doesn't work is because I'm not running the server.
I'm sure I've done a great many things wrong, but what's strange is that this all used to work, even with all the things I've probably done wrong or left out. I hope someone can help. Thanks a lot.
PS. Here's how the Realm Browser behaves when I try to access my realm in various ways:
(you can see by the number of options I'm trying that I don't really know which is which/which one I'm supposed to use. Again, one of these worked in the past, but I don't remember which)
Open Sync URL, realm://XX.YYY.ZZZ.AA:9080/~/ gives the "Please provide valid credentials to access this Realm" dialog. And I am pretty damn sure I'm entering the correct credentials.
Open Sync URL, http://XX.YYY.ZZZ.AA:9080/~/ leaves the "Connect" button disabled
Connect to Object Server, realm://XX.YYY.ZZZ.AA:9080/ gives "Could not connect to the server."
Connect to Object Server, http://XX.YYY.ZZZ.AA:9080/ leaves the "Connect" button disabled

I've got an EC2 instance running. I've run
start-object-server.command.
start-object-server.command is for running local instances of the Realm Object Server; the ones accessible via http://localhost:9080. You might need to be careful since if you're running a local instance of ROS locally, as well as trying to connect to one remotely on AWS, there might be some confusion as to which server you ended up talking to. :)
I've pasted the code for my setupRealm() method.
That code looks correct. Just remember that if you ran start-object-server.command, you would have been presented with the localhost instance of ROS automatically, so those credentials wouldn't exist on your EC2 instance at present.
I also can't log in to my synced realm using the Realm Browser, though I am able to open local (non-synced) realms from the iOS simulator. And I am running the latest version of Realm Browser.
That's normal behavior. You can open local Realm files in the Browser, but for ones created with the Realm Mobile Platform, you'll need to connect to them; you cannot open them directly. If you can't connect to a Realm, that either means the Realm Mobile Platform isn't running, or isn't configured for the right URLs properly.
I had a play with setting up my own EC2 instance, and I got it working as intended. You can tell if it's working because you should be able to navigate to your public DNS URL with port 9080 and see the Realm Mobile Platform dashboard login page. (eg 'http://ec2-00-000-000-00.compute-1.amazonaws.com:9080').
It's possible that while you set up an EC2 instance, the Realm Mobile Platform itself wasn't installed too. If that's the case, you can easily manually install RMP by connecting to your instance via SSH and running the Ubuntu installation script:
# Setup Realm's PackageCloud repository
curl -s https://packagecloud.io/install/repositories/realm/realm/script.deb.sh | sudo bash
# Update the repositories
sudo apt-get update
# Install the Realm Object Server
sudo apt-get install realm-object-server-developer
# Enable and start the service
sudo systemctl enable realm-object-server
sudo systemctl start realm-object-server
But the crux of the matter is that you need to confirm you can access your Realm Mobile Platform dashboard on your EC2 in order to confirm that the Object Server is indeed running, and you've set the proper credentials. Good luck!

Related

Postgres, Prisma Working Fine One Day, 'P1001 Error: Can't Reach Database' the next

For this project, I am using a prisma / Postgres database. I have made no changes to my code, and I have pulled a coworkers working version of the code to no avail. I am unable to do anything with the database, I cannot migrate, I cannot run mutations, and I cannot even open the psql console, as every command is met with
P1001: Can't reach database server at localhost:5432
Please make sure your database server is running at localhost:5432
I am not sure what I could have possibly done, I don't know enough about ports or even the contents of app.json well enough to have messed anything up. Now, no mutations can go through.
Interestingly enough, this all happened after I ran npx primsa migrate deploy on the deployed database which is on a EC2 VM from AWS. Since then, the native app associated with the database refuses to work, though it is worth nothing that the webapp connects to the deployed database just fine. This being said, nothing works locally, as the database / Port / Server don't exist anymore according to my machine, which makes no sense. I have no idea how to try to re-spin it, or why every single query / mutation from my Native App now ONLy returns Response not successful: Received status code 400 despite it having the same exact syntax it did when it worked, as well as the WebApp having the same syntax and server (ExpressJS). Does anyone have any ideas what could be causing this?
The error code 400 refers to a bad request coming from the client: too large request, malformed syntax, invalid request message framing, etc.
First step: make sure that your database server is indeed running. Try connecting to it with other SQL Clients or Libraries. Sometimes Prisma is just being difficult.
Second thing: are you hosting the database on the local server? I can assume you are because of the localhost. Make sure no other programs are using this port or maybe waiting for it.
Sorry if this doesn't help. Good luck!

Heroku App Only Working On Local Machine

Have something really odd going on with Heroku.
I have an application build in React/JS/Node with Mongo.
If I pull up the link to my app on my local machine: https://obscure-crag-61417.herokuapp.com/, I can see a version of my website, but it is not updating for any changes that I push to Heroku.
Even more strange, is that on a non-local machine, if i visit the aforementioned link, I get the boilerplate 'Express' page.
I've tried clearing the cache, exiting browsers on both PC's but same old story.
I have the MongoDB config set in Heroku.
Not sure what could be going on here.
Any ideas?
PS--here's my code: https://github.com/pythoncreate/twit-stocks
Okay i figured this one out. I'm pretty sure it was how I was setting the ports on the backend. Heroku has some specific rules about this:
Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)

AEM login screen is not apprearing in a linux machine AEM6.3

I have set up AEM 6.3 on remote Linux machine. But when I try to access the AEM from browser, it says "Connection has timed out".
I am not getting any error in the error.log file. Also, in stdout.log file, it says "Startup completed".
Also, I checked that port(4502) is not blocked on the server.
When I put command "curl http://localhost:4502/" on the server, I am not getting any error, which makes me assume that the connection is established.
Do I need to do any other configuration or something in order to access it from the browser? I am using http://ip:4502/ in the browser..
Almost certainly a firewall issue, check and check again :)
Look in the AEM Access log (same folder as the other logs you looked in) can you see any requests coming in from your browser? There is no other config required on AEM to access other than starting it up, assuming there is nothing network/firewall related blocking then you should be able to access it.

Host GitLab in VirtualBox

I tried the prepared VirtualBox stack from bitnami, which I run in bridged mode, but could not pull/push through SSH, I would get prompted with a password request. I have no idea what kind of password this guy wants from me, since none of them worked and I would always get access denied.
I then disabled passwords in the sshd configuration file on the server, since I want to work with keys anyway, defined my own authorized_keys and added public keys for a sample user.
I then got the message:
no supported authentication methods available (server sent: publickey)
I tried calling the repository through HTTP, but this would not enforce any permissions.
I tried setting up my own Virtual Machine with the installer from GitLab, but despite doing everything from tutorials I can't connect to GitLab from outside the VM.
Why and what kind of password does tortoise gitplink want from me? Why can't I use the keys public keys that are placed in the default location on my Windows, and also in a file authorized_keys on the server I am referring to in the sshd configuration file, why does it tell me that there is no authorization method after I disable passphrases?

ZSS initial setup failing with invalid connection string

I am trying to get the Zumero for SQL Server working and I cannot get past running the test client. I get the below error
Connection string in web.config is
<settings temp_directory="C:\ProgramData\Zumero\ZSS Server\temp\"
odbc_connection_string="DSN=krishna;User Id=syncadmin;Password=syncadmin;"
license_key="<removed>" />
The description for Event ID 1 from source Zumero cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Error -1 (mssql): {"diag":[{"SQL_DIAG_MESSAGE_TEXT":"[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database \"ZumeroTest\" requested by the login. The login failed.","SQL_DIAG_NATIVE":4060,"SQL_DIAG_SQLSTATE":"42000"},{"SQL_DIAG_MESSAGE_TEXT":"[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed","SQL_DIAG_NATIVE":0,"SQL_DIAG_SQLSTATE":"IM006"},{"SQL_DIAG_MESSAGE_TEXT":"[Microsoft][ODBC SQL Server Driver]Invalid connection string attribute","SQL_DIAG_NATIVE":0,"SQL_DIAG_SQLSTATE":"01S00"}],"SQLRETURN":-1}
..\..\..\src\core\sg\sg_mssql.c:344
..\..\..\src\core\sg\sg_mssql.c:384
..\..\..\src\core\server\zum_db_mssql.c:2896
..\..\..\src\core\server\zum_respond.c:4454
..\..\..\src\servers\iis\main.cpp:1211
The publisher has been disabled and its resource is not avaiable. This usually occurs when the publisher is in the process of being uninstalled or upgraded
Either the SQL Server user doesn't have rights or the database doesn't exist.
You can use a DSN, but for troubleshooting purposes I recommend putting the connection details directly in the connection string for now. Once it's working you can migrate the settings back to a DSN if you like.
Looks like you're using SQL Server authentication. So the odbc_connection_string value should look like this:
Driver={SQL Server Native Client 11.0};Database={database};Server={server.ad.domain.com};UID={sql_server_user};PWD={password};
The database must exist and the user specified must have appropriate read/write access to it.
(If you're setting minimum necessary permissions, you'll also want to make sure the user has VIEW SERVER STATE rights, as described here.)
While unrelated to your invalid connection string problem, the messages about The description for Event ID 1 [...] and The publisher has been disabled [...] indicate that ZSS hasn't been correctly registered with the Windows Event Viewer. Did you install the server by hand (from the .zip file) or using the installer?
You can fix those messages using the following command (which probably requires an admin prompt):
wevtutil im "PATH\TO\events.man" /rf:"PATH\TO\zumero_server.dll" /mf:"PATH\TO\zumero_server.dll"
where PATH\TO is the path where you extracted those files from the .zip. If you used the installer then they should be located at: %PROGRAMFILES%\Zumero\ZSS Server
If you installed manually from the .zip then it's worth noting that the instructions had a subtle typo in that command which would cause it to fail. That typo has been fixed in the past few days, but it may have caught you during your installation and caused this issue.