Coder Social home page Coder Social logo

Comments (5)

joaoventura avatar joaoventura commented on June 10, 2024

Can I suggest you to try to implement a simple example using just python's httplib, and not using requests? Maybe there are some android permissions that are blocking your http requests..

from pybridge.

trbedwards avatar trbedwards commented on June 10, 2024

I've constructed an example which uses http.client (the python3 version of httplib).

In bootstrap.py:

from http.client import HTTPConnection

def router(args):
    # same as usual

def http_request(args):
    conn = HTTPConnection("www.google.com")
    print("sending request")
    conn.request("GET", "/")
    print("getting response")
    r1 = conn.getresponse()
    print(r1.status, r1.reason)
    return str(r1.status)

routes = {
    'http_request' : http_request
}

and in MainActivity.java we call json.put("function", "http_request").

I get the same errors as before. If I don't copy _socket.so and the other .so files into the python directory I get ImportError: no module named '_socket'. If I do copy all the .so files, then I get a SIGSEGV error which I've tracked down to a call of the _socket.getaddrinfo function.

from pybridge.

trbedwards avatar trbedwards commented on June 10, 2024

Ah, you were right about the android permissions!
I added the following line to my AndroidManifests.xml file:

Now everything works :)

from pybridge.

trbedwards avatar trbedwards commented on June 10, 2024

How do I then tell pybridge to use the correct architecture specific _socket.so file? At the moment I'm manually copying _socket.so from the arm64-v8a libs in the crystax ndk, but I guess there's a more elegant automated way to do this?

from pybridge.

joaoventura avatar joaoventura commented on June 10, 2024

Glad it worked for you.. 👍
I don't have any solution to automatically copy python files by architecture as I want to keep pybridge simple to understand and "hack"..

from pybridge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.