python2 sockets can't connect to python3 sockets - python-2.7

I was trying to code a simple server client program in python and when i ran the server using python3 and tried to have the client connect to it using python2, it would throw an error:
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
however, when i ran the same short program on the same computer using python2 and python3, it would connect. The 2 separate computers would only connect if they were using the same version of python. Is there a reason for this and a way around this?
#client
s=socket.socket()
s.connect(('ip, port))
#server
s=socket()
s.bind(('', port))
s.listen(4)
c, addr = s.accept()

Your Windows software firewall has python.exe marked as allowed but not python3.exe.

Related

Connecting to Could SQL from local machine via proxy

I am following these instructions to deploy a Django app on Google App Engine:
https://cloud.google.com/python/django/appengine
I have got as far as downloading the proxy .exe file (I am on a Windows machine) and connecting to it:
2019/01/08 16:14:08 Listening on 127.0.0.1:3306 for
[INSTANCE-NAME] 2019/01/08 16:14:08
Ready for new connections
When I try and create the Django migrations by running python manage.py createmigrations I see the connection received by the proxy file:
2019/01/08 16:15:06 New connection for
"[INSTANCE-NAME]"
However, after a couple of seconds pause I get this error:
2019/01/08 16:15:28 couldn't connect to
"[INSTANCE-NAME]": dial tcp
35.205.185.133:3307: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I have tried disabling my local firewall in case this was causing any issues, but the result is the same. I've also checked the username, password and Cloud SQL instance name, they are all correct.
What could be causing this error?

Won't create a PostgreSQL database on Unix server

I am trying to deploy my django project to a unix server. When I run the command to create the PostgreSQL database using SSH, I encounter the following error:
$ createdb elections
createdb: could not connect to database template1: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Does the error mean running 'locally' as in the server or my machine?
What is stopping it from connecting to the server?
How do I fix the error?

Connection refused to mysql database from C++ driver

Problem
I'm following tutorial on Connect/C++ provided by dev.mysql. After copying the example and successfully compiling and linking it, I run into following issue:
terminate called after throwing an instance of 'sql::SQLException'
what(): Can't connect to MySQL server on '127.0.0.1' (111)
From what I know 111 stands for Permission Denied.
Setup
Here is the example code taken from here and slightly modified:
#include <mysql_driver.h>
int main()
{
auto driver = sql::mysql::get_mysql_driver_instance();
auto con = driver->connect("tcp://127.0.0.1:0", "root", "123");
delete con;
}
Trying with tcp://127.0.0.1:3306 give the same result.
Here is the CMakeLists.txt:
cmake_minimum_required(VERSION 3.9)
project(mysql_try)
set(CMAKE_CXX_STANDARD 14)
set(SOURCE_FILES main.cpp)
add_executable(mysql_try ${SOURCE_FILES})
target_include_directories(mysql_try PUBLIC /usr/local/include/mysql++)
target_link_libraries(mysql_try mysqlclient /usr/local/lib/libmysqlcppconn-static.a pthread dl)
I can easily run mysql with the credentials in the code. I disabled networking, so that it would only listen on localhost. Running
mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';
gave me 0, so I guess it is port 0.
C Connector and command line interfaces work just fine.
My OS is ubuntu 16.04.
I disabled networking, so that it would only listen on localhost.
There's a difference between disabling networking all together (tcp) and specifying tcp to listen ONLY on your loopback adapter (127.0.0.1). Your mysql client is almost certainly connecting via Unix Socket, not TCP, which is why that works fine. Verify that by running mysql --protocol tcp. If that fails, then you know you disabled TCP connections all together, and it's connecting via Unix Socket.
connect("tcp://127.0.0.1:0"
If you did disable networking with skip-networking you need to change your connect() to reference your socket file instead. See the docs
unix://path_name
This URL format enables use of Unix domain socket files for connections to the local host on Unix and Unix-like systems. The path_name value is the socket file path name, just as for the --socket option of MySQL clients such as mysql and mysqladmin running on Unix (see Connecting to the MySQL Server).
Find your socket with:
mysql> SHOW GLOBAL VARIABLES LIKE 'socket'
If you want to keep your connect string the same, remove skip-networking and instead add
bind-address = 127.0.0.1
That should fix it!

pycharm remote debugging: failed to find free socket

I'm trying to use remote debugging but get this error on pycharm:
Error running remoteTest:
failed to find free socket
My remote host is Ubuntu |(with username and password) and my localhost is windows, I followed the following tutorial:
https://blog.jetbrains.com/pycharm/2010/12/python-remote-debug-with-pycharm/
and I used a ssh tunnel on putty to connect to the server.
import pydevd
pydevd.settrace('localhost', port=21000, stdoutToServer=True, stderrToServer=True)

Connection with neo4j-client failed on OS X yosemite

I've tried to establish a connection by both command line and in my C++ project.
In a "secure" version I received:
OpenSSL error: 336130315:SSL routines:SSL3_GET_RECORD:wrong version number
If I try with an insecure connection, I received:
connection to 'neo4j://localhost:7474' failed: Could not agree on a protocol version
but I successfully access to the db via browser on the same port number.
How could I repair?
An insecure connection is good for me.