Attempting to establish a connection to a python grpc server developed with grpcio through a web browser using connect-query. Encountering an issue where upon making a request, an ERR_INVALID_HTTP_RESPONSE error is displayed in the browser. Below is the React App component:
// [...]
import { TransportProvider } from '@bufbuild/connect-query';
import { createConnectTransport } from '@bufbuild/connect-web';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
const queryClient = new QueryClient();
const transport = createConnectTransport({
baseUrl: "http://localhost:50051",
useBinaryFormat: true,
});
class App extends React.Component {
render() {
return (
<Suspense fallback='loading'>
<Provider store={store}>
<TransportProvider transport={transport}>
<QueryClientProvider client={queryClient}>
<RouterProvider router={router} />
</QueryClientProvider>
</TransportProvider>
</Provider>
</Suspense>
);
}
}
Testing the following component:
export function MyController() {
const { data } = useQuery(login.useQuery());
console.log(data)
return <MyView />;
}
The python server code:
import asyncio
import grpc
import uvloop
from grpc_reflection.v1alpha import reflection
from .status.servicer import StatusServicer, status_pb2, status_pb2_grpc
async def serve() -> None:
server = grpc.aio.server()
status_pb2_grpc.add_StatusServicer_to_server(StatusServicer(), server)
service_names = (
status_pb2.DESCRIPTOR.services_by_name["Status"].full_name,
reflection.SERVICE_NAME,
)
reflection.enable_server_reflection(service_names, server)
server.add_insecure_port('[::]:50051')
await server.start()
await server.wait_for_termination()
if __name__ == '__main__':
with asyncio.Runner(loop_factory=uvloop.new_event_loop) as runner:
runner.run(serve())
Is there something missing? It is my understanding that connect-query does not require a proxy and should connect automatically.