Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server connection problem #534

Open
MegaSova opened this issue Apr 29, 2023 · 0 comments
Open

Server connection problem #534

MegaSova opened this issue Apr 29, 2023 · 0 comments

Comments

@MegaSova
Copy link

code:


#!/usr/bin/env python3
f = open("/etc/hostname", "r")
lines = f.read().split('\n')
bric_name = lines[0]
f.close()
from time import sleep
import threading
import ev3dev2
import ev3dev2.sound
import evdev
#import gamepad
import rpyc
from rpyc.utils.server import ThreadedServer

print(bric_name)

print(rpyc.version)

if bric_name == "ev3devfrontright":
sound = ev3dev2.sound.Sound()
class MyService(rpyc.Service):
def on_connect(self):
print("new connect")
pass

    def on_disconnect(self):
        print("disconnect")
        pass
    
    def exposed_getmodule(self):
        pass

if __name__ == '__main__':
    print("starting server")
    s = ThreadedServer(MyService, port=18812)
    print("server creat")
    s.start()

elif bric_name == "ev3devfrontleft":
pass

elif bric_name == "ev3devbackright":
pass

elif bric_name == "ev3devbackleft":
print("start connect")
conn = rpyc.classic.connect('192.168.0.2')
print("connect accept")
sleep(5)
while True:
print("OK")
sleep(5)

pass

2 controllers
server: ev3devfrontright
client: ev3devbackleft
server starts.

when the client knocks on the server, it joins and immediately disconnects with an error:


Traceback (most recent call last):
File "/home/robot/blrpyc/main.py", line 55, in
conn = rpyc.classic.connect('192.168.0.2')
File "/usr/lib/python3/dist-packages/rpyc/utils/classic.py", line 68, in connect
return factory.connect(host, port, SlaveService, ipv6 = ipv6, keepalive = keepalive)
File "/usr/lib/python3/dist-packages/rpyc/utils/factory.py", line 90, in connect
return connect_stream(s, service, config)
File "/usr/lib/python3/dist-packages/rpyc/utils/factory.py", line 51, in connect_stream
return connect_channel(Channel(stream), service = service, config = config)
File "/usr/lib/python3/dist-packages/rpyc/utils/factory.py", line 40, in connect_channel
return Connection(service, channel, config = config)
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 151, in init
self._init_service()
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 154, in _init_service
self._local_root.on_connect()
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 146, in on_connect
self._conn.eval = self._conn.root.eval
File "/usr/lib/python3/dist-packages/rpyc/core/netref.py", line 150, in getattr
return syncreq(self, consts.HANDLE_GETATTR, name)
File "/usr/lib/python3/dist-packages/rpyc/core/netref.py", line 71, in syncreq
return conn.sync_request(handler, oid, *args)
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 441, in sync_request
raise obj
AttributeError: 'MyService' object has no attribute 'exposed_eval'

========= Remote Traceback (1) =========
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 305, in _dispatch_request
res = self._HANDLERS[handler](self, *args)
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 541, in _handle_getattr
return self._access_attr(oid, name, (), "_rpyc_getattr", "allow_getattr", getattr)
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 507, in _access_attr
return accessor(obj, name, *args)
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 69, in _rpyc_getattr
return getattr(self, name)
AttributeError: 'MyService' object has no attribute 'exposed_eval'


Exited with error code 1.


the server says that the client joined and immediately connected.

rpyc 3.3.0
python 3.10
oc windows 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant