I have a web service built on spring-camel. I am trying to integrate the grpc server using grpc-spring-boot-starter. My implementation of grpc service is as below.
#GrpcService
public class GreetingServiceImpl extends GreetingServiceGrpc.GreetingServiceImplBase {
#Override
public void processGrpcRequest(GreetingRequest request, StreamObserver<GreetingResponse> responseObserver) {
String receivedMessage = request.getRequest();
GreetingResponse response = GreetingResponse.newBuilder()
.setResponse("Your message received " + receivedMessage).build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
}
I package my web service as a war and I find no error during deployement of the war file in my application server. However, when I try to communicate with my grpc server, I get the following error message.
Exception in thread "main" 15:18:01.363 [grpc-nio-worker-ELG-1-2] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x02a01ffb, L:/127.0.0.1:56000 - R:localhost/127.0.0.1:9089] INBOUND PING: ack=true bytes=1234
io.grpc.StatusRuntimeException: UNIMPLEMENTED: HTTP status code 404
invalid content-type: text/html
headers: Metadata(:status=404,content-type=text/html,date=Fri, 04 Mar 2022 09:48:01 GMT,content-length=74)
DATA-----------------------------
<html><head><title>Error</title></head><body>404 - Not Found</body></html>
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
at com.test.grpc.GreetingServiceGrpc$GreetingServiceBlockingStub.processGrpcRequest(GreetingServiceGrpc.java:156)
at com.test.grpc.GrpcClient.main(GrpcClient.java:16)
I have recreated the same issue with minimal setup and code is available here github . Please can anyone help on this. Thanks
Related
I Want to Connect to get data from facebook using restFb but it is throwing Unknown host Exception .
My code
package com.resrfb;
import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
import com.restfb.types.User;
public class SimpleMeExample {
public static void main(String[] args) {
FacebookClient facebookClient= new DefaultFacebookClient("Key");
User user = facebookClient.fetchObject("me", User.class);
System.out.println("User="+ user);
System.out.println("UserName= "+ user.getUsername());
System.out.println("Birthday= "+ user.getBirthday());
}
}
Also i wanted to know how to get data from any user that login to my web app using restfb as here i am geeting my accesstoken manually how to get it for any user when logging in using facebook sdk.
Stack Trace
Exception in thread "main" com.restfb.exception.FacebookNetworkException: A network error occurred while trying to communicate with Facebook: Facebook request failed (HTTP status code null)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1024)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:952)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:914)
at com.restfb.DefaultFacebookClient.fetchObject(DefaultFacebookClient.java:392)
at com.resrfb.SimpleMeExample.main(SimpleMeExample.java:14)
Caused by: java.net.UnknownHostException: graph.facebook.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:559)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:141)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:272)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:329)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:172)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:158)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:133)
at com.restfb.DefaultWebRequestor.execute(DefaultWebRequestor.java:374)
at com.restfb.DefaultWebRequestor.executeGet(DefaultWebRequestor.java:96)
at com.restfb.DefaultFacebookClient$3.makeRequest(DefaultFacebookClient.java:965)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1022)
... 4 more
Your machine cannot connect to Facebook, this error is on a lower level and not RestFB dependent. You should check your DNS settings, hosts file and your proxy settings.
My configuration as follows. XUnit runner (1.9.2) fires tests generated using SpecFlow. IISExpress 10 starts in singleton like this:
_iisProcess = new Process {
StartInfo = {
FileName = Path.Combine(programFiles, #"IIS Express\iisexpress.exe")
}
};
var applicationPath = GetApplicationPath();
_iisProcess.StartInfo.Arguments = string.Format(
"/path:{0} /port:{1} /systray:false /trace:e",
applicationPath,
IisPort); // so far 9090
_iisProcess.Start();
Selenium IEDriverServer.exe (2.46) configured as this:
_driver = new InternetExplorerDriver(
new InternetExplorerOptions(){EnsureCleanSession = true});
The machine configured as per this guide. IEDriverServer.exe listens 17923 port.
At some points in tests IISExpress fails with "Access violation" (c0000005) error. The actual fail system test varies but looks like it happens when there is some active UI interaction. There is SignalR, dynamic content and other. The Problem signature:
Problem Event Name: APPCRASH
Application Name: iisexpress.exe
Application Version: 10.0.10046.0
Application Timestamp: 55121079
Fault Module Name: webengine4.dll
Fault Module Version: 4.6.57.0
Fault Module Timestamp: 551b8b21
Exception Code: c0000005
Exception Offset: 00066ccf
OS Version: 6.3.9600.2.0.0.256.48
Locale ID: 1049
Additional Information 1: 5861
Additional Information 2: 5861822e1919d7c014bbb064c64908b2
Additional Information 3: a10f
Additional Information 4: a10ff7d2bb2516fdc753f9c34fc3b069
Sometimes it fails at code like this with "OpenQA.Selenium.WebDriverTimeoutException : Timed out after 30 seconds" at DefaultWait.Until
IWait<IWebDriver> wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30.00));
try
{
wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));
}
catch (InvalidOperationException ex) // js error { /*...*/ }
IISExpress log also does not help. It writes some last requests only and terminates:
Request started: "POST" http://localhost:9090/signalr/abort?transport=webSockets...
Request ended: http://localhost:9090/signalr/connect?transport=webSockets... with HTTP status 101.0
Request ended: http://localhost:9090/signalr/abort?transport=webSockets&clientProtocol=1.4.... with HTTP status 200.0
WriteCompletedInline
Action = 00000002
Action = 00000000
Request ended: http://localhost:9090/signalr/connect?transport=webSockets.... with HTTP status 101.0
Request ended: http://localhost:9090/BotDetectCaptcha.ashx?get=image&c=SampleCaptcha&t=44c45e60afac46809bfce16e123b54a2 with HTTP status 200.0
It does not help if the tests run under Administrator. The same when R# test runner fires the tests.
Any your thoughts, help would be much appreciated. Thanks!
In case it would be helpful someone it helped me to solve the problem by the reinstallation of IIS Express. IIS Express 8.0 MSI file could be found at here.
I have a working SignalR application that allows me to connect multiple JavaScript clients and exchange data. When I tried to connect with a .NET client I get the following error:
An exception of type 'Microsoft.AspNet.SignalR.Client.HttpClientException' occurred in mscorlib.dll but was not handled in user code
Additional information: StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Transfer-Encoding: chunked
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcRGFycmVuXERlc2t0b3BcQ29uc29sZUFwcGxpY2F0aW9uMVxXZWJBcHBsaWNhdGlvbjFcc2lnbmFsclxuZWdvdGlhdGU=?=
Cache-Control: private
Date: Thu, 28 May 2015 09:13:06 GMT
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Content-Type: text/html; charset=utf-8
}
To remove as many variables as possible I copied the Hub into an brand new web application and copied the .NET client code into a console application. I still get the same exception. Here is my client code:
Dim hubConnection As HubConnection
Dim chatHubProxy As IHubProxy
Public Async Sub RunTest()
System.Net.ServicePointManager.DefaultConnectionLimit = 10
hubConnection = New HubConnection("http://localhost:64400")
hubConnection.Credentials = Net.CredentialCache.DefaultCredentials
hubConnection.TraceLevel = TraceLevels.All
hubConnection.TraceWriter = Console.Out
chatHubProxy = hubConnection.CreateHubProxy("Chat")
AddHandler hubConnection.StateChanged, Sub(stateChange) Console.WriteLine("[" & DateTime.Now & "]: " & stateChange.OldState.ToString() & " => " & stateChange.NewState.ToString() & " " & hubConnection.ConnectionId)
chatHubProxy.On(Of String, String)("ReceiveMessage", Sub(from, message) Console.WriteLine(message))
Await hubConnection.Start()
End Sub
Here is the console output:
09:21:54.3952161 - null - ChangeState(Disconnected, Connecting)
[28/05/2015 10:21:54]: Disconnected => Connecting
[28/05/2015 10:21:56]: Connecting => Disconnected
09:21:56.8448452 - null - Disconnected
09:21:56.8458461 - null - Transport.Dispose()
09:21:56.8468465 - null - Closed
And here is my hub code:
public class ChatHub : Hub
{
public void SendMessage(string name, string message)
{
Clients.All.ReceiveMessage(name, message);
}
}
This turned out to be a trivial mistake, but the error message was so useless I'm sure others will be stumped by the same issue. The name of the hub was wrong. I used "Chat" when I should have used "ChatHub".
If the exception had been 404, or "Hub not found" or something like that it would have been an easy fix rather than a couple of wasted hours!
#Michael Tiller's comment in #Darren's answer turned out to be the solution for my problem, so I think it's fair to make this into its own answer:
Changing the Hub class to public solved my problem. I followed an example and missed the text that said to create a PUBLIC class that inherits from Hub, and when adding a new class in Visual Studio, by default it creates it as
class TestHub
{
}
...which is technically internal (see here). More careful reading on my part would have prevented this, but in case someone else got in too big of a hurry like I did... :)
Real issue was resolved but i think it's important to realise that SignalR server returning status 500 (Internal Server Error) (not very informative error indeed) is security feature.
If you need more information on server errors, you can do following:
1) Enable tracing on server
and\or
2) Enable detailed exception messages send to client (don't do that in production!):
SignalR 1.x:
RouteTable.Routes.MapHubs(new HubConfiguration { EnableDetailedErrors = true });
SignalR 2.x
public void Configuration(IAppBuilder app)
{
var hubConfiguration = new HubConfiguration
{
#if DEBUG
EnableDetailedErrors = true
#else
EnableDetailedErrors = false
#endif
};
app.MapSignalR(hubConfiguration);
}
I was doing similar trivial mistake took few hours to figure it out.
[HubName("Hostsync")] // Missed to add this attribute in Hub of SignalR Self Host
public class ChatHub : Hub
{
}
But i was trying to connect by defining the proxy name in Client.
HostProxyName = "Hostsync";
Just make sure there is no such kind of mistakes. Since you will not be getting the exact detailed exception during the connection establishment.
The following link helped me to address few things
Stackoverflow Question Answer Link
Hope this helps.,
I had the same issue. I found out that the SignalR Jquery extension version was older than the referenced SignalR library. I corrected the script version and problem solved. If you have recently upgraded the SignalR to newer version, you would probably face the same issue like me.
I am trying to call an external webservice running outside my machine and i have written the rout logic using camel framework
Routing Code:
from("direct:test1").process(new Processor() {
#Override
public void process(Exchange arg0) throws Exception {
arg0.getOut().setBody("testmessage");
}
}).to("cxf://http://localhost:8085/FinEdge-General/xrmServices/2011/Organization.svc?serviceClass=com.hcl.flsl.integration.msdn.crmwcf.IOrganizationService&defaultOperationName=Retrieve")
But when i execute the program i am getting the below error.
Error
org.apache.cxf.transport.http.HTTPException: HTTP response '415:
Cannot process the message because the content type 'text/xml;
charset=UTF-8' was not the expected type 'application/soap+xml;
charset=utf-8'.' when communicating with
\\http://localhost:port/FinEdge-General/xrmServices/2011/Organization.svc
Note: Webservice is developed in .NET(WCF) and SOAP 1.2.
It looks like the CXF is sending the message with SOAP 1.1, you need to let it switch to SOAP 1.2 by apply the WSDL file as the serviceClass you use is not has that information.
BTW, you can find difference between the SOAP 1.1 message and SOAP 1.2 message here.
As #Willem Jiang mentioned, you have to change the SOAP version to 1.2 . I do it programmatically:
service = Service.create("your service name");
service.addPort("your port", SOAPBinding.SOAP12HTTP_BINDING, "your url");
I need to make a handshake. I do it with the code below.
I'm running the code in an applet and it works fine when running directly against the server. The problem I have occurs when the same code runs via a proxy.
I'm looking in the java console with trace level 5 activated. Directly after the code line "SSLSocket socket = (SSLSocket) factory.createSocket("www.theserver.com", 443);" is executed
this line appears in the java console "network: Connecting http://www.theserver.com:443 with proxy=DIRECT". After this the applet stops working. I think it is because the
proxy will not allow http traffic on port 443.
Can anyone tell me why it is connecting using http and what I should do to make it connect using https?
import javax.net.ssl.HandshakeCompletedEvent;
import javax.net.ssl.HandshakeCompletedListener;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
public class Handshake
{
class MyHandshakeListener implements HandshakeCompletedListener
{
public void handshakeCompleted(HandshakeCompletedEvent e)
{
System.out.println("Handshake succesful!");
System.out.println("Using cipher suite: " + e.getCipherSuite());
}
}
public void DoHandshake()
{
try
{
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) factory.createSocket("www.theserver.com", 443);
String[] suites = socket.getSupportedCipherSuites();
socket.setEnabledCipherSuites(suites);
socket.addHandshakeCompletedListener(new MyHandshakeListener());
socket.startHandshake();
}
catch (Exception e)
{
System.out.println(e);
}
}
}
I know this is a little late, but we had the exact same problem and was just able to resolve it. The problem was on the client, the "Use SSL 2.0 compatible ClientHello format" was checked on the advanced tab of the Java Control Panel. Uncheck this box on the client and it will connect correctly.