API网关在微服务式架构中是否总是必需的?(Are API Gateways always necessary in a Microservice styled architecture?)
我在网上看到过API网关成为客户端请求入口点的例子。 API网关在微服务式架构中是否总是必需的?
I have seen examples on the net where API gateway becomes the entry point for the client requests. Are API Gateways always necessary in a Microservice styled architecture ?
原文:https://stackoverflow.com/questions/35875489
最满意答案
经过几天(!)的研究,我终于找到了一个非常简单的解决方案:HTTP访问控制(CORS)。
长话短说 - 下面的代码解决了这个问题。
我必须在我的服务器上执行以下步骤:
1.)激活apache的头模块:
server# a2enmod mod_headers
2.)在我的服务器上修改VirtualHost文件“myservice.conf”并在其间添加以下行。
Header set Access-Control-Allow-Origin "*"
3.)检查文件中的任何错误:
server# apachectl -t
4.)重新加载并重启apache
server# service apache2 reload && service apache2 restart
5.)享受服务器客户端连接!
希望我能帮助任何有同样问题的人!
After some days(!) of research I finally found the very simple solution: HTTP access control (CORS).
Long story short - the following code fixed the problem.
I had to take the following steps on my server:
1.) Activate headers module for apache:
server# a2enmod mod_headers
2.) Modify VirtualHost file "myservice.conf" on my server and add the following line between.
Header set Access-Control-Allow-Origin "*"
3.) Check for any errors in your file:
server# apachectl -t
4.) reload and restart apache
server# service apache2 reload && service apache2 restart
5.) Enjoy the server client connection!
Hope I could help anyone who has the same problem!!
相关问答
更多-
在发送任何内容之前,您的服务器正在等待客户端的数据: Cli_sock, addr = s.accept() print "Cli_sockected with " + addr[0] + " " + str(addr[1]) # get message from client message = Cli_sock.recv(BUFFER_SIZE) 发送任何内容之前,您的客户端正在等待服务器中的数据: s.connect((TCP_IP, TCP_PORT)) print "Established co ...
-
经过几天(!)的研究,我终于找到了一个非常简单的解决方案:HTTP访问控制(CORS)。 长话短说 - 下面的代码解决了这个问题。 我必须在我的服务器上执行以下步骤: 1.)激活apache的头模块: server# a2enmod mod_headers 2.)在我的服务器上修改VirtualHost文件“myservice.conf”并在其间添加以下行。 Header set Access-Control-Allow-Origin "*" 3.)检查文件中的任何错误: server# apachec ...
-
服务器只能接受n个客户端(Server can accept n clients only)[2023-08-29]
无需使用signal() 。 例: #include#include #include #include #include main() { int s = socket(PF_INET, SOCK_STREAM, 0); // server socket if (s == -1) return perror("socket"), ... -
客户端可以确定服务器是否接受()'da unix套接字?(Can a client determine whether the server has accept()'d a unix socket?)[2023-08-24]
我想说的答案是改变协议,以便服务器先说话(比如SMTP,不像HTTP) 内核在accept()系统调用之前已经接受套接字; 如果它从未到达,那么套接字就处于等待状态。 没有办法将它与接受连接但不说话的服务器区分开来。 这是BSD套接字一直工作的方式。 Looks like the answer to this is "no"; the kernel offers no way to get at this info. (change the protocol isn't an answer, since I ... -
我不熟悉lua,但我的理解是你正在为套接字写一个新的行,你想在Android端接收。 通常情况下,如果是这种情况,您需要获取inputStream而不是输出,因为您正在等待结果。 此外,您需要无限期地(或者直到满足某些条件)在单独的线程(标准输入)上监听数据的输入流: while(true){ if (inputStreamReader().read() != -1){ // do you processing } } My notebook was changing ...
-
一种方法是在服务器端集线器中添加新方法并从客户端调用它。 将此方法添加到服务器中的集线器: public void AcknowledgeServer(String ack) { // Do your stuff. } 并稍微修改一下客户端代码: _hub.On("RcvSendToUser", x => { Console.WriteLine(x); // Now call the server method with the string value. _hub.Invoke("Ac ...
-
当服务器套接字接受客户端套接字时,究竟发生了什么?(What things are exactly happening when server socket accept client sockets?)[2022-05-31]
当服务器套接字执行accept()时,它会创建一个新的(客户端)套接字,该套接字绑定到与端口服务器套接字绑定不同的端口。 因此套接字通信是通过新绑定端口完成的,服务器套接字(仅限于accept())正在等待最初绑定端口上的另一个客户端连接。 没有。 我认为这不是很正确的答案 这是一个错误的答案。 因为(1)端口匹配到单个进程 这并不意味着任何相关。 (2)套接字是内部处理事务 这也不是。 它实际上并不意味着什么。 而单个进程可以有多个套接字。 这是真的,但它对你答案错误的原因没有任何影响。 您的答案错误的原 ... -
这是服务器不接受TSL回切重新协商的问题,这是Stunnel默认提供的功能,无法通过配置进行更改。 所以我不得不修改stunnel的源代码以强制它在每次建立连接时进行握手。 It was a problem with the server not accepting TSL handsake renegotiation, a feature that comes by default with Stunnel and cannot be changed via configuration. So I had ...
-
你忘了绑定到套接字: if( bind(s , (struct sockaddr*)&si_other, sizeof(si_other) ) == -1) { fprintf(stderr, "bind failed\n"); exit(1); } The problem was in the message header. The part Via has to end with ;rport, so asterisk does actually ...
-
客户端/服务器不接受ObjectInput和Output流(ObjectInput and Output streams are not being accepted by client/server)[2022-02-15]
您需要在两端的ObjectInputStream之前创建ObjectOutputStream。 You need to create the ObjectOutputStream before the ObjectInputStream at both ends.