error 16550 : "not authorized for query on " mongolab - ruby-on-rails

I have a Rails application running on heroku and i am connecting at two dbs hosted in mongolab (X and Y).
I have configured two heroku env variables containing the connection strings.
When i query on Y all works fine but when i query on X db it gives me the error 16550 : "not authorized for query on X.table".
I have setted up correctly both env variables for these connections and also have a valid user to access X db.
If i connect with the shell all works fine.
How can i solve this?
Here is the error message in rails:
{"status":"500",
"error":"The operation: #<Moped::Protocol::Query\n #length=88\n #request_id=4\n #response_to=0\n
#op_code=2004\n #flags=[:slave_ok]\n
#full_collection_name=\"X.table\"\n
#skip=0\n #limit=0\n
#selector={\"_id\"=>\"5252c92521e4af681a000002\"}\n
#fields=nil>\n
failed with error 16550: \"not authorized for query on X.table\"\n\n
See https://github.com/mongodb/mongo/blob/master/docs/errors.md\nfor details about this error."}

I solved this, if someone comes here with the same problem : look at your table model, if as in my case it is "stored_in" another database you must specify there the session of the the uri = evn variables on datbase.yml

Related

ServiceUnavailable error in cypher statement from guides.neo4j.com/wiki

I recently created a Neo4j sandbox instance (blank) so I could test https://guides.neo4j.com/wiki.
Using https://guides.neo4j.com/wiki, I had success running the first cypher statement to populate the graph with Wikipedia categories. However, the second cypher statement produces an error - after running for a few seconds.
Here's the statement:
UNWIND range(0,4) as level
CALL apoc.cypher.doIt("
MATCH (c:Category { pagesFetched: false, level: $level })
CALL apoc.load.json('https://en.wikipedia.org/w/api.php?format=json&action=query&list=categorymembers&cmtype=page&cmtitle=Category:' + apoc.text.urlencode(c.catName) + '&cmprop=ids%7Ctitle&cmlimit=500')
YIELD value as results
UNWIND results.query.categorymembers AS page
MERGE (p:Page {pageId: page.pageid})
ON CREATE SET p.pageTitle = page.title, p.pageUrl = 'http://en.wikipedia.org/wiki/' + apoc.text.urlencode(replace(page.title, ' ', '_'))
WITH p,c
MERGE (p)-[:IN_CATEGORY]->(c)
WITH DISTINCT c
SET c.pagesFetched = true", { level: level }) YIELD value
RETURN value
And here's the error message:
Error ServiceUnavailable
WebSocket connection failure. Due to security constraints in your web browser, the reason for the failure is not available to this Neo4j Driver. Please use your browsers development console to determine the root cause of the failure. Common reasons include the database being unavailable, using the wrong connection URL or temporary network problems. If you have enabled encryption, ensure your browser is configured to trust the certificate Neo4j is configured to use. WebSocket `readyState` is: 3
The js console shows error message:
neo4j-web.min.js:20 WebSocket is already in CLOSING or CLOSED state.
I also posted this on the neoj4 Slack channel and the neo4j Google group - any help is appreciated.
As an addendum to this post (5/25/2018):
I installed neo4j community edition version 3.4.0 on an AWS EC2 (Linux) instance, and did not get the ServiceUnavailable error as above. The error occurred on my MacBook Pro macos 10.13.4
Thanks for your interest.
Colin Goldberg

Unable to issue identity in Hyperledger Composer

I am trying to issue an identity to a participant that already exists in the network.
return this.bizNetworkConnection.connect(this.cardname)
.then((result) => {
let email = 'user#gmail.com',
username = email.split('#')[0];
this.businessNetworkDefinition = result;
return this.bizNetworkConnection.issueIdentity('org.test.Person#user#gmail.com', username);
})
.then((result) => {
console.log(`userID = ${result.userID}`);
console.log(`userSecret = ${result.userSecret}`);
})
I expect that I will see the userID and the userSecret logged on the console but I am getting errors as described below.
Following the developer tutorial on their documents:
If I use the card name for PeerAdmin#hlfv1 on the connect function above, I get the error. "Error trying to ping. Error: Error trying to query business network. Error: Missing \"chaincodeId\" parameter in the proposal request"
If I use the card name for admin#tutorial-network on the connect function above, I get the error "fabric-ca request register failed with errors [[{\"code\":400,\"message\":\"Authorization failure\"}]]"
For option 1, I know the network name is missing in the given card, whie option 2 means that the admin has no rights to issue an identity. However, I cannot seem to find any documentation directing me on how to use either to achieve my objective. Any help is highly welcome.
While I have listed the javascript code I am using to achieve the same, I would not mind if anyone can explain what I am missing using the composer cli.
see https://hyperledger.github.io/composer/latest/managing/identity-issue.html
you would definitely use the admin#tutorial-network card, as PeerAdmin does not have authority to issue identities (admin does).
Did you already do: 1) a composer card import -f networkadmin.card (per the tutorial) ? 2) a composer network ping -c admin#tutorial-network to use the card (now in the card store) and thereby populate the admin's credentials (certificate/private key).
Only at that point would admin be recognised as the identity to issue further identities. Is it possible you spun up a new dockerized CA server at some stage since you did the import etc ?
What happens if you issue a test identity through the command line (using admin#tutorial-network? Does it fail)

How to turn on icloud sharing on Production environment?

I have a key in Myapp.entitlements:
com.apple.developer.icloud-container-environment
and value: Development.
With above when I try to share the record using UICloudSharingController then everything is fine, and it is shared. But when I change above key to Production what is intended for me, it doesn't work.
Always got a response:
Failed to modify some records. What is going on?
Should I somewhere turn it on? A new entity in cloudkit dashboard or something else?
The exact error is:
Optional(<CKError 0x1c144b520: "Partial Failure" (2/1011); "Failed to modify some records"; uuid = 7580FED7-25A0-430C-A16C-610A506F4309; container ID = "iCloud.pl.blueworld.fieldservice"; partial errors: {
Share-54BD438F-BA4F-46EE-8B71-403CFA780D3F:(fieldservice:__defaultOwner__) = <CKError 0x1c1448c10: "Invalid Arguments" (12/2006); server message = "Cannot create a new type in production schema"; uuid = 7580FED7-25A0-430C-A16C-610A506F4309>
... 1 "Batch Request Failed" CKError's omitted ...
}>)
This line in the error message looks like the problem:
server message = "Cannot create a new type in production schema";
It looks like you haven't deployed your (latest) schema from the dev environment to the prod environment in the cloudkit dashboard. You've just told your app to look at the prod environment.

Get Client Machine Name in Ruby on Rails

How do I get the client (not the server) machine name in Rails from a controller? I've tried Socket.gethostnamebut that just get's the name of the server the Rails app is running on. Resolv.getname(request.remote_ip) just gives back an error saying there is no name for the client's IP address. I'm on Rails v4 if that matters.
I had the same problem using Resolv, I ended up doing this, as it is not always possible to retrieve the name of a machine from an ip address:
dns_lookup = ""
begin
dns_lookup = Resolv.getname(request.remote_ip)
rescue Resolv::ResolvError => e
end

Trouble with authlogic_rpx

I'm trying to run http://github.com/tardate/rails-authlogic-rpx-sample (only rails version was changed) but get error message http://gist.github.com/385696, when RPX returns information after successful authentication via Google Account. What is wrong here? And how I can fix it?
The code was successfully tested with rails 2.3.3 by its author: http://rails-authlogic-rpx-sample.heroku.com/
I run on Windows with cygwin and rails (2.3.5), rpx_now (0.6.20), authlogic_rpx (1.1.1).
Update
In several hours RPX rejected my app http://img96.imageshack.us/img96/2508/14128362.png
Update2
The same error message ( http://gist.github.com/386124) appears with http://github.com/grosser/rpx_now_example , but in this case RPX allows me to sign in (so far).
Solved
See below
Got error: Invalid parameter: apiKey (code: 1), HTTP status: 200
You have to first register your RPX app at http://www.RPXnow.com and set its name. You'll be assigned an API key which you should set in the config/environment.rb file:
RPX_API_KEY = ENV["RPX_API_KEY"]
RPX_APP_NAME = "your_app_name_here!"
Or: Read slide 35: http://www.slideshare.net/tardate/srbauthlogicrpx
You shouldn't have any constraints enforced at the database level.
The reason was trailing \r character in my API key. Apparently, non of the steps did key trimming and the exception was not processed in a good way.

Resources