Django + PyOrient : db_create socket.timeout exception in EC2 - django

I'm using orientDB community version 2.2.35 and pyorient 1.5.5.
client.db_create(db_name, pyorient.DB_TYPE_GRAPH, pyorient.STORAGE_TYPE_PLOCAL)
This runs perfectly fine locally after starting the server.
But when I run the same code on an ec2 machine, it throws socket.timeout exception.
I initially thought it could be a CORS issue, but it's not. What else could be the issue?

Running the orientDB server using sudo command fixed the issue.
db_create() tries to modify OSystem/dirty.fl file and I got permission denied exception on server logs.
FileNotFoundException: /home/ubuntu/orientdb-community-2.2.35/databases/OSystem/dirty.fl (Permission denied)

Related

Unable to connect google compute engine, getting permission denied error

I have accidentally changed permission of the .ssh folder to 600 and now I am not able to log in to the GCP server through SSH as it's giving me permission denied error.
**Connection Failed**
You cannot connect to the VM instance because of an unexpected error. Wait a few moments and then try again.
I tried multiple options like, ssh troubleshooting instance, enabling serial console, ssh private key login.
Thanks you in advance.
One of the simple ways to fix this would be to use a startup script. In this script just execute chmod 700 /path/to/your/.ssh.
The startup scripts are executed with root privileges, so it should be able to fix your problem with .ssh folder permissions.
So, what you need to do:
Set the startup script.
Restart the VM.
Wait a minute or two to make sure the script got executed.
Remove the startup script from the machine. (no need to restart again)
Thank you guys for all your support, my problem got solved by follwing below document:
Serial Console with local password using a startup script

Unable to connect to Huggingface from EC2 instance

I am running a python code in EC2 instance where I am loading a Huggingface model using the from_pretrained() method. I get the error
OSError: Couldn't reach server at 'https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-config.json' to download pretrained model configuration file.
while trying to initialize the reader. To get over this, I downloaded the file manually and provided the local JSON path. That worked fine but then I see issues in loading the tokenizer too.
OSError: Couldn't reach server at '{}' to download vocabulary files.
I think my network settings of EC2 are not correct due to which I am unable to connect to external Huggingface repository.
I tried relaxing the inbound rules for EC2 to IP version|Type|Protocol|Port range|Destination=>IPv4|All|traffic|All|All|0.0.0.0/0 but even that doesn't help. The outbound rules are already IPv4|All|traffic|All|All|0.0.0.0/0.
I also tried creating an IAM role with policy AmazonS3ReadOnlyAccess and attached it to the EC2 instance but still getting the same error.
Could someone point what needs to be done to solve this. Thanks.
Here is how i fixed this issue.
i installed pyopenssl like this :
!pip install pyopenssl
then i restarted terminal and re-ran the code and it fixed the issue for me,thanks
might be your network is using proxy
this might help
$ proxies = {"http": 'foo.bar:3128', addyourproxy:'foo.bar:4012'}
$ from transformers import pipeline
$ qt_ans = pipeline('question-answering')

Running sqlpackage.exe from AWS CodeDeploy throws an exception

I'm attempting to run sqlpackage.exe from a script executed by AWS CodeDeploy.
The sqlpackage command runs fine from a local CMD prompt when logged in as the administrator but does not run when called as part of the CodeDeploy pipeline.
The following error occurs:
An unexpected failure occurred: DacInstance with the specified instance_id does not exist..
Unhandled Exception: System.Data.SqlClient.SqlException: DacInstance with the specified instance_id does not exist.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
It would appear that a connection cannot be made to the database.
CodeDeploy runs as a windows service running under aLocal System account where as my command prompt where this works runs under the Administrator account. This is the only difference so I think this must be permissions issue.
It would appear that a dacpac needs to be installed by a user with sysadmin privileges. I attempted (as a test) to set the SQL Server user NT AUTHORITY\SYSTEM to have a role of DBCreator.
The deployment then failed with the following error.
The database settings cannot be modified. You must be a SysAdmin to apply these settings.
The database settings cannot be modified. You must be a SysAdmin to apply these settings.
An error occurred while the batch was being executed.
Updating database (Failed)
I am unsure how to proceed however. I'm guessing that making NT AUTHORITY\SYSTEM a SysAdmin is a bad idea!
CodeDeploy Host Agent Service runs as LocalSystem user, which should have NT AUTHORITY\SYSTEM and BUILTIN\Administrators privileges.
This is how the CodeDeploy agent executes your script:
powershell.exe -ExecutionPolicy Bypass -File <absolute_path_to_your_script_here>
You can try putting the executable on the root along with the appspec.yml file if you are putting it in a folder within your deployment package.
That being said, we have seem this issue with the older versions of host agent which should be resolved with the latest version released in March, 2017.

Permission denied. Error code: 3 Error message from server: Permission denied

I am logging into my amazon aws production box using WinSCP and i have successfully setup Tomcat 6. But in webapps folder when i transfer some webservice i get error as:
Permission denied.
Error code: 3
Error message from server: Permission denied
Please help me out to resolve this issue
You haven't mentioned what instance type you are using, but it sounds like you are on some flavor of Linux. You need to chmod or chown the webapps directory so you can place files there, or you can place them elsewhere (like your home directory), then log in and use sudo mv to move it in place.

Error: "The security token included in the request is invalid" when using Boto python

I am getting this error when I run my django project on nginx. I use dynamodb for database and S3 for serving static files in the project. The project runs fine when operated on localhost.
The project originally was hosted in another ec2 instance where it ran like charm. I fired up a new ec2 instance from an image of that instance. And now it is throwing this error.
The thing is,
the connection works fine when I run some test code on the command
line.
But throws this error when the project runs.
JSONResponseError at /
JSONResponseError: 400 Bad Request
{u'message': u'The security token included in the request is invalid.', u'__type': u'com.amazon.coral.service#UnrecognizedClientException'}
Request Method: POST
Request URL: http://ec2-54-200-144-115.us-west-2.compute.amazonaws.com/?attempt=1&code=AQBfOzPR4Hlgrpkjz-qXQj8b7OLq6cm1NM_oZf64Wz3EmlX2-VDS6qfZ5V5f0Tmbx4MrLc4SGuJxUHa8drQClz3A1IWMVqUGKLEEW_0ol1RqClI8cZViWreBm5c3HJ-Vp48Xx81a7gvXSjRNJUn-kazXqahDrgsAeLez_8FrXIb_HWHyekhnUmxgkskRGBNzcTtpqASNe3agzG3ZZowCMYi6bDBAdVuODli3ApWQWENSmjLaN5QbZWbGo3ATvJNMAUQjj6VTHCkVS-UWcuh-PtwAAFtUqb8HkLsbFG31KevwPKz6x10ojD45pe03zA1SF_g
Django Version: 1.5
Exception Type: JSONResponseError
Exception Value:
JSONResponseError: 400 Bad Request
{u'message': u'The security token included in the request is invalid.', u'__type': u'com.amazon.coral.service#UnrecognizedClientException'}
Exception Location: /srv/www/test/local/lib/python2.7/site-packages/boto/dynamodb2/layer1.py in _retry_handler, line 1530
Python Executable: /srv/www/test/bin/python
Python Version: 2.7.3
Can't understand what's going on. Can anyone help me?
You are getting this message since the security credentials / Access Keys for your AWS account has been changed.
Try again with new access keys it will work.
All the best.
Are you using a newer version of python 2.7? I had a similar error with this because of the ssl fixes.
I was doing this and it worked
import ssl
# for fix to python on mac which is newer than the one on linux
ssl._create_default_https_context = ssl._create_unverified_context
because none of the solutions worked here was the solution for me.
on a mean stack, I had to run as sudo
sudo forever start startme.js
or
sudo node startme.js
when i did NOT use 'sudo', I received the error:
UnrecognizedClientException: The security token included in the request is invalid.