I've installed and run cldwalker's datomic-free receipe https://github.com/cldwalker/datomic-free on an EC2 instance.
;=> System started datomic:free://{EC2 private IP address}:4334/<DB-NAME>,
; storing data in: data
My free-transactor.properties file looks like this:
protocol=free
host={EC2 private IP address}
port=4334
h2-port=4335
h2-web-port=4336
I want to connect the database from outside EC2:
(require '[datomic.api :as d])
(def uri "datomic:free://{EC2 public IP address}:4334/om_async?h2-
port=4335&h2-web-port=4336&aws_secret_key={xxx}&aws_access_key_id={yyy}")
(d/create-database uri)
But I get:
clojure.lang.ExceptionInfo: Error communicating with HOST
{EC2 private IP address} on PORT 4334 :: {:timestamp 1418304487036,
:host "{EC2 private IP address}", :version "0.9.5078", :port 4334,
:username "{XXX}", :peer-version 2, :alt-host nil, :password "{YYY}",
:encrypt-channel true}
What should I do to make this work?
UPDATE:
I have found the "Free Transactor on EC2" thread in the Datomic Google Group: https://groups.google.com/d/msg/datomic/wBRZNyHm03o/0SdNhqjF27wJ
Does this means I can only connect to Datomic-free if my app run on the same server?
Would I have the same problem (not being able to access db from outside server) if I get Datomic-free hosted on linode or digitalocean?
Thanks in advance for your help!
I had a very similar problem ("Error communicating with HOST
on PORT 4334") and all I had to do was restart my computer, strangely enough. Something with the ports being tied up after having launched a local transactor, I think. Then again, you probably already tried that.
To allow remote peers access to embedded storage you must do three things:
choose two passwords for the embedded storage
set the storage-access property
add a password to the connection URI used by peers
Take a look at this link
Related
As I tried to run the chat app from localhost connected to MySQL database which had been coded with PHP via WebSocket it was successful.
Also when I tried to run from the PuTTY terminal logged into SSH credentials, it was displaying as Server Started with the port# 8080
ubuntu#ec3-193-123-96:/home/admin/web/ec3-193-123-96.eu-central-1.compute.amazonaws.com/public_html/application/libraries/server$ php websocket_server.php
PHP Fatal error: Uncaught React\Socket\ConnectionException: Could not bind to tcp://0.0.0.0:8080: Address already in use in /home/admin/web/ec3-193-123-96.eu-central-1.compute.amazonaws.com/public_html/application/libraries/vendor/react/socket/src/Server.php:29
Stack trace:
#0 /home/admin/web/ec3-193-123-96.eu-central-1.compute.amazonaws.com/public_html/application/libraries/vendor/cboden/ratchet/src/Ratchet/Server/IoServer.php(70): React\Socket\Server->listen(8080, '0.0.0.0')
#1 /home/admin/web/ec3-193-123-96.eu-central-1.compute.amazonaws.com/public_html/application/libraries/server/websocket_server.php(121): Ratchet\Server\IoServer::factory(Object(Ratchet\Http\HttpServer), 8080)
#2 {main}
thrown in /home/admin/web/ec3-193-123-96.eu-central-1.compute.amazonaws.com/public_html/application/libraries/vendor/react/socket/src/Server.php on line 29
ubuntu#ec3-193-123-96:/home/admin/web/ec3-193-123-96.eu-central-1.compute.amazonaws.com/public_html/application/libraries/server$
So I tried to change the port#8080 to port# 8282, it was successful
ubuntu#ec3-193-123-96:/home/admin/web/ec3-193-123-96.eu-central-1.compute.amazonaws.com/public_html/application/libraries/server$ php websocket_server.php
Keeping the shell script running, open a couple of web browser windows, and open a Javascript console or a page with the following Javascript:
var conn = new WebSocket('ws://0.0.0.0:8282');
conn.onopen = function(e) {
console.log("Connection established!");
};
conn.onmessage = function(e) {
console.log(e.data);
};
From the browser console results:
WebSocket connection to 'ws://5.160.195.94:8282/' failed: Error in
connection establishment: net::ERR_CONNECTION_TIMED_OUT
websocket_server.php
<?php
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use MyApp\Chat;
require dirname(__DIR__) . '/vendor/autoload.php';
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Chat()
)
),
8282
);
$server->run();
I even tried to assign Public IP and Private IP, but with no good it resulted in the same old result?
This was the composer files generated after executing and adding src folder $composer require cboden/ratchet
composer.json(On AmazonWebServer)
{
"autoload": {
"psr-4": {
"MyApp\\": "src"
}
},
"require": {
"cboden/ratchet": "^0.4.1"
}
}
composer.json(On localhost)
{
"autoload": {
"psr-4": {
"MyApp\\": "src"
}
},
"require": {
"cboden/ratchet": "^0.4.3"
}
}
How am I suppose to resolve/overcome while connecting it from the WebSocket especially from the hosted server with the domain name such as
http://ec3-193-123-96.eu-central-1.compute.amazonaws.com/
var conn = new WebSocket('ws://localhost:8282');
From the Security Group
Under Inbound tab
Under Outbound tab
When it comes to a connectivity issue with an EC2 there are few things you need to check to find the root cause.
SSH into the EC2 instance that the application is running and make sure you can access it from within the EC2 instance. If it works then its a network related issue that we need to solve.
If step 1 was successful. You have now identified it is a network issue to solve this you need to check the following.
Check if an Internet Gateway is created and attached to your VPC.
Next check if your subnets routing table has its default route pointing to the internet gateway. check this link to complete this and the above step.
Check your subnets Network ACLs rules to see if ports are not blocked
finally, you would want to check your Instances Security group as you have shown.
If you need access via a EC2 dns you will need to provision your ec2 instance in a public subnet and assign an elastic IP
If an issue still exists check if the EC2 status checks pass, or try provisioning a new instance.
I have launched an aws neptune instance and installed apache-tinkerpop-gremlin-console version 3.3.3 on windows 10 machine.
neptune-remote.yml looks like:
hosts: [abc-nept.XXXXXX.us-XXXX-1.neptune.amazonaws.com]
port: 8182
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}
after running gremlin.bat next command is:
:remote connect tinkerpop.server conf/neptune-remote.yaml
Now at this stage I am able to make queries and those are working! So question is how can I check whether I am actually connected to aws neptune instance or not?
I assume your question is related to having multiple :remote instances configured. Obviously, if you've simply created:
:remote connect tinkerpop.server conf/neptune-remote.yaml
then the only place your data could be going to or coming from is Neptune. The Console does allow multiple :remote instance that you can switch between so if you also had one for a local Gremlin Server then you might want to confirm which one you're sending requests. You just do this:
gremlin> :remote
==>Remote - Gremlin Server - [localhost/127.0.0.1:8182]
You'll be able to see the "current" :remote and thus know whether it is for Neptune or your local Gremlin Server instance.
I have deployed a datomic transactor to an AWS cloud formation, connected to a DyanmoDB as storage. I'm able to connect to the transactor if I go to my local datomic directory (version 0.9.5.44) and use the repl:
=> (def uri "datomic:ddb://us-east-1/datemo/test-db?aws_access_key_id={xxx}&aws_secret_key={yyy}")
=> (def conn (d/connect uri))
#object[datomic.peer.Connection 0x5e5ddfbc "{:unsent-updates-queue 0, :pending-txes 0,:next-t 1000, :basis-t 63, :index-rev 0, :db-id \"test-db-ab4b8028-e25b-4431-b2a2-c7173b4c9918\"}"]
If, however, I do the same in my project's repl, it does not work, and instead I get the following error:
CompilerException java.lang.NoClassDefFoundError: Could not initialize
class datomic.ddb_cluster__init,
compiling:(form-init1336530578825920965.clj:1:11)
Incidentally, if I try to connect to my usual datomic dev transactor it works just fine. Does anyone know what I might be doing wrong here? The error seems to suggest that the class is not even present...
You need to include both the Datomic Peer library and the AWS SDK as dependencies in your project to connect to a DDB-backed instance.
This section of the documentation: http://docs.datomic.com/storage.html#sec-6-1 contains details of including the AWS SDK.
-Marshall
I have created a project in Go using gin and it is working fine locally. However, when I tried deploying this on an EC2 instance on AWS, I was unable to access the APIs on the server.
I did a ssh into the hosted machine and gave a curl request (curl localhost:8080) and it gave a proper response. But any request from outside is not reachable.
The server is running on port 8080. I have opened the ports in the AWS security groups.
Is there any setting in Go/gin that I need to make for it to be accessible from the internet?
Sample code:
package main
import (
"myConstants"
"myDatabase"
"myMiddleware"
"onboarding"
"github.com/gin-gonic/gin"
)
func main() {
var db = myDatabase.DBConnect()
router := gin.Default()
router.Use(myMiddleware.RestrictInputContent)
router.Use(myMiddleware.CheckToken(db))
router.Use(myMiddleware.RequestLoggerMiddleware())
router.POST("/signup", onboarding.Signup(db))
router.POST("/login", onboarding.Login(db))
router.POST("/logout", onboarding.Logout(db))
router.GET("/", onboarding.Hello(db))
defer db.Close()
//Listen and serve
router.Run("127.0.0.1:8080")
}
Changed the router.Run from router.Run("127.0.0.1:8080") to router.Run(":8080") and it works.
As suggested by #elithrar and #user3591723
127.0.0.1 (local host) is only the loop back interface on the machine
Binding to ":8080" means 0.0.0.0:8080 - which means all interfaces
Using clojure.java.jmx I'm trying to connect with JMX server protected with username/password:
(jmx/with-connection {:host "my.server", :port 50001 :environment {"jmx.remote.credentials" ["username" "password"]}} (jmx/mbean "java.lang:type=OperatingSystem"))
But what I get is:
ClassNotFoundException clojure.lang.PersistentVector (no security manager: RMI class loader disabled) sun.rmi.server.LoaderHandler.loadClass (LoaderHandler.java:396)
Aby thoughts what's happened here?
aghh... sorry guys. I just found a reason. as a clojure newbe I tried to send environment parameters as clojure Vector instead of java array of Strings. Following is the snippet which solves my problem:
(jmx/with-connection {:host "my.server", :port 50001 :environment {"jmx.remote.credentials" (into-array String ["username" "password"])}} (jmx/mbean "java.lang:type=OperatingSystem"))