rpc

打下rpc

一曲冷凌霜 提交于 2019-12-03 12:13:16
什么是RPC RPC(Remote Procedure Call)是远程过程调用,比如说现在有两台服务器A, B,一个在A服务器上的应用想要调用B服务器上的应用提供的某个,由于不在两个方法不在一个内存空间,不能直接调用,需要通过网络表达调用的语义和传达调用的数据。常存在于分布式系统中。 RPC要解决的问题 建立通信:在客户端与服务端建立起数据传输通道。著名的 [gRPC]( grpc / grpc.io ) 使用的 http2 协议,也有如dubbo一类的自定义报文的tcp协议。 寻址:A服务器上的应用需要告诉RPC框架:B服务器地址、端口,调用函数名称。所以必须实现待调用方法到call ID的映射。 序列化与反序列化:由于网络协议都是二进制的,所以调用方法的参数在进行传递时首先要序列化成二进制,B服务器收到请求后要再对参数进行反序列化。恢复为内存中的表达方式,找到对应的方法进行本地调用,得到返回值。返回值从B到A的传输仍要经过序列化与反序列化的过程。序列化协议如基于文本编码的 xml json,也有二进制编码的 protobuf hessian等。 其实RPC需要了解的基本内容就是上面,我们最想知道这个名词与一般的HTTP相比有啥优势,解决了什么问题。 OSI模型 什么是Http 超文本传输协议,是一个基于请求与响应,无状态的,应用层的协议,常基于TCP/IP协议传输数据

Session management in gwt

人盡茶涼 提交于 2019-12-03 11:53:43
I am using GWT for my client side application. However, I am not sure how I can handle session management. The GWT application resides on one page, all server calls are done via AJAX. If a session expires on the server. let's assume the user didn't close the browser, and sending some request to server using RPC, how could my server notify the application that the session has expired and that the client side portion should show the login screen again?My sample code : ContactDataServiceAsync contactDataService = GWT .create(ContactDataService.class); ((ServiceDefTarget) contactDataService)

SpringBoot之Dubbox

橙三吉。 提交于 2019-12-03 11:46:33
上次springboot集成dubbo写过一个简单的demo调用的方式,由于spring版本的问题,这次使用duboox,完全基于注解的方式。 dubbox 地址: https://github.com/dangdangdotcom/dubbox 由于dubbox没有发布到maven中央仓库,需要自己安装到本地maven库或者私库 git clone https://github.com/dangdangdotcom/dubbox 在dubbox目录执行mvn install -Dmaven.test.skip=true来尝试编译一下dubbo(并将dubbo的jar安装到本地maven库) 1.导入maven依赖 <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>3.4.6</version> <exclusions> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.101tec</groupId>

Cross-platform general purpose C++ RPC library [closed]

你离开我真会死。 提交于 2019-12-03 09:10:51
Here's the task: Imagine, we have an applications and a plug-in for it (dynamic library). Interface between the application and the plug-in is completely defined. Now I need to run the application and the plug-in on different computers. I wrote a stub for the plug-in on a computer where the real applications is running. And the application loads it and calls its functions like if it were a native plug-in. On the other computer there's a stub instead of the real application, which loads the native plug-in. Now I need to organize RPCs between my stubs over the network, regardless the very

Can XML-RPC methods be called by name (as strings) in Python?

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In python, calling XML-RPC methods involves invoking methods on a proxy object: from xmlrpclib import ServerProxy print ServerProxy('https://example.com/rpc').api.hello_there('John') In some other languages, like perl, you pass your method name as a method parameter. use Frontier::Client; $p = Frontier::Client->new(url => 'https://example.com/rpc'); $result = $p->call('api.hello_there', 'John'); print $result; Is there a way to invoke XML-RPC methods by name, as strings, in Python? 回答1: Just use getattr , as with any Python object. func =

How to set rpc timeout in thrift python client?

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm writing python client using thrift, but I can't find any available option to set rpc time out. My client code goes below: socket = TSocket.TSocket(address, port) transport = TTransport.TBufferedTransport(socket) protocol = TBinaryProtocol.TBinaryProtocol(transport) server = Client.Client(protocol) transport.open() 回答1: You can use socket.setTimeout() method. from thrift.transport.THttpClient import THttpClient socket = THttpClient(server_url) socket.setTimeout(SERVICE_TIMEOUT_IN_mS) transport = TTransport.TBufferedTransport(socket)

How do we handle Python xmlrpclib Connection Refused?

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I don't know what the heck I'm doing wrong here, I wrote have an RPC client trying to connect to a non-existent server, and I'm trying to handle the exception that is thrown, but no matter what I try I can't figure out how I'm supposed to handle this: def _get_rpc(): try: a = ServerProxy('http://dd:LNXFhcZnYshy5mKyOFfy@127.0.0.1:9001') a = a.supervisor return a except: return False rpc = _get_rpc() if not rpc: print "No RPC" Since there is no server running, I would expect the output to be "No RPC" but instead I get an exception: Traceback

Does RPC have a timeout mechanism?

喜夏-厌秋 提交于 2019-12-03 08:49:39
If RPC does not have a timeout mechanism, how do I "kill" an RPC call if it is trying to call an RPC method of a server that is closed? You can use channels to implement a timeout pattern: import "time" c := make(chan error, 1) go func() { c <- client.Call("Service", args, &result) } () select { case err := <-c: // use err and result case <-time.After(timeoutNanoseconds): // call timed out } The select will block until either client.Call returns or timeoutNanoseconds elapsed. if you want to implement a timeout (to prevent a call from taking too long), then you'll want to change rpc.Dial for

JAX-RPC / JAX-WS runtime in Apache Tomcat

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am using Apache Tomcat v6 server. While creating a new Web Service, I get the Web service runtime options for "Apache Axis", "Apache Axis2" and "Apache CXF2.x". Is it possible to have the runtime as "JAX-RPC" or "Jax-WS"? EDIT: I am using Eclipse IDE 回答1: JAX-RPC and JAX-WS are specifications, Axis, Axis2 and CXF are implementations. for JAX-RPC you need Axis (1) for JAX-WS use CXF (I believe Axis2 also supports this spec but I've never used it) If you have a choice I strongly recommend the latter (JAX-WS) as it's the more modern

Python Remote Procedure Call (Without the Remote Part)

陌路散爱 提交于 2019-12-03 08:37:32
I have a Python server which is not running as root, which fronts an application I am developing. However there are some application features which require access to RAW sockets which means root privileges. Obviously I do not want to run the main server as root, and so my solution is to create a daemon process or command line script which runs as root providing guarded access to said features. However I want put aside stdin/stdout communication and use an RPC style of interaction such as Pyro . But this exposes the RPC interface to anyone with network access to the machine, whereas I know that