Is it possible to run a gRPC server on iOS?
Let’s say we want to use the gRPC framework to define APIs etc. And now we want to deploy a gRPC server in the same process with the application using it — connection via an InprocessChannel.
Is there a gRPC port for iOS that allows to do that?
Yes, unlike with the Objective-C bindings for gRPC, it's possible to run a gRPC server on iOS using Swift GRPC:
APIs and generated code is provided for both gRPC clients and servers,
and can be built either with Xcode or the Swift Package Manager.
Support is provided for all four gRPC API styles (Unary, Server
Streaming, Client Streaming, and Bidirectional Streaming) and
connections can be made either over secure (TLS) or insecure channels.
The Echo example contains a Mac app that demonstrates both server and client code. The Swift gRPC parts should be similar in an iOS app.
It is not officially supported by gRPC, but you have a couple of options to do this on your own:
You can wrap gRPC C++ and use their server feature. Someone tried this before and seems worked.
You can use the gRPC Swift repo which has gRPC server feature on iOS client.
Related
I am using the e-signature Java SDK for the application that I developed.
The application will run on a docker container and the container on a Linux server.
There is a proxy configured on this server and I have been asked if there is anything that they have to configure regarding DocuSign integration.
This answer on GitHub says that SDK would automatically pick up the proxy settings of the system.
What happens on my case. Will it pick the server or the container settings. Should I manually set the proxy settings in code?
Unfortunately I do not have access to the system (or to any similar system) so it is not possible to test the application.
The answer you linked to (https://github.com/docusign/docusign-esign-java-client/issues/152#issuecomment-653926077) talked about an enhancement request that will enable a specific ApiClient with its own proxy for the Java SDK.
You do need to update the proxy settings in your code if you know what they are.
I am trying to do some tries with xamarin android and gRPC.
I have my service running in my computer, and I have a net standard 2.1 library with the gRPC client. If I use this library in a wpf application in the same computer, I get response from server, but if I use this library in my xamarin proyect, that I run in a virtual machine with android 8.0, I get the message error connection closed by peer.
In the xamarion prject, the address that I am using is https://10.0.2.2:5001. I am using the IP 10.0.2.2 because if I am not wrong, it is the IP that is used to communicate with localhost.
How could I solve this problem?
Thanks.
PD: I have set permissions to application to can use internet.
PD: I have realized that if my WPF application I use https://localhost:5001 it works, but if I use https:x.x.x.x:5001 where x.x.x.x is the IP of the computer, it gives the same error.
Xamarin works with native nugets Grpc.Core and Grpc.Core.Api
It wont work with Grpc.Net.Client
Find more on
https://learn.microsoft.com/en-us/aspnet/core/grpc/client?view=aspnetcore-3.1
Calling gRPC over HTTP/2 with Grpc.Net.Client is currently not supported on Xamarin. We are working to improve HTTP/2 support in a future Xamarin release. Grpc.Core and gRPC-Web are viable alternatives that work today.
I am currently communicating with my Redis instance from my iOS client using a websocket. I specify the host address and the listening port and execute some Redis Commands from my IOS client directly.
The reason I am doing that because I am doing real live geolocation tracking and executing these commands from my backend which is in php will result in latency.
I am afraid that this is not the most secure way because if someone knows my host address and ports he will be able to access my Redis Instance.
My question is how can I communicate with my Redis Instance from my iOs client using a websocket but in a more secure way.
#Ahmed,
I read the answer provided by #ThatCampbellKid and the comments and understand your wish to have the iOS client communicate directly with the Redis server.
However, Redis was NOT designed for this approach. As indicated in the documentation (emphasis added):
Redis is designed to be accessed by trusted clients inside trusted environments.
The internet is not a trusted environment and the direct access allows Redis to be accessed by non-trusted clients.
The same documentation gives the following example (emphasis added):
In the common case of a single computer directly exposed to the internet, such as a virtualized Linux instance (Linode, EC2, ...), the Redis port should be firewalled to prevent access from the outside. Clients will still be able to access Redis using the loopback interface.
The correct approach would be to use a dynamic application to authenticate clients and bridge between clients and the Redis server.
You can use JWT (the nginx module suggested by #ThatCampbellKid), PHP, Ruby, node.js, Java, C or whatever you want - but you will need to use something.
I'm sorry to say this, but any other shortcut will expose your system to security risks.
EDIT:
Yes, you can still use WebSocket.
The difference is that this architecture is not secure:
Client <=(WebSockets)=> Redis
And this architecture is secure (if implemented correctly):
Client <=(WebSockets)=> Authentication Layer <=(TCP)=> Redis
There are a couple ways of doing it, depending on how your project is set up. You could add an NGINX loadbalancer in front of your php/redis containers that accepts JSON Web Tokens for authentication.
https://www.nginx.com/blog/authentication-content-based-routing-jwts-nginx-plus/
Redis has the ability to do authentication as well, but isn't considered best practices it looks like, but you can find more information about it here also:
https://redis.io/commands/auth
As you said you are already running Nginx then have a look at the Nchan websockets module
Your Nginx install can then serve websocket connections directly and it has support for several methods of client authentication as well as direct integration with redis
We are developing an application which needs to consume AWS IoT service based on a MQTT protocol deviation. We are currently facing issues to get connected with MQTT broker provided by AWS IoT cloud server.
Following is the environment:
iOS Version: 8.0 / 9.0
Programming language: Swift
Library for MQTT: Moscapsule
Steps followed:
Set initial config clientid, host, port
Set client certificate with private key, providing .pem file path (e.g. cert.pem, privateKey.pem)
Set server certificate which is root certificate .pem file path (e.g. rootCA.pem)
Set tls opts with tsl_insecure: false, cert_reqs: SSL_VERIFY_PEER, tls version: tlsv1.2, ciphers: nil
Problems faced:
When trying to connect to server/broker gives error “unable to create TLS_Context”.
With setting tls cert_reqs: SSL_VERIFY_NONE, gives connection status success with subcribe and publish sucess, but doesn’t reflect on server or broker.
Any help in this context is highly appreciable.
The AWS SDK for iOS already supports connecting to AWS IoT over MQTT. You can see an example Swift program which transfers data to and from AWS IoT over MQTT using certificate-based authentication here. If you'd like to use a different MQTT client and just need to know how to set it up, you might start with the AWS SDK for iOS, and then have a look at the code involved in setting up the TLS connection.
Thanks for using AWS IoT.
I need to run a client server application in corba using c++ without using name service or without managing a shared file.
Basically want to run the server on one port and client should connect to this.
But the port will be read in client side and this needs to be communicated to server.
Is there a way to achieve this communicating the port from client to server.