Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create topic return error 400 Bad Request #29

Open
Tera opened this issue Jun 9, 2017 · 0 comments
Open

Create topic return error 400 Bad Request #29

Tera opened this issue Jun 9, 2017 · 0 comments

Comments

@Tera
Copy link

Tera commented Jun 9, 2017

Hi

i was trying version 1.28 of your library with a local env of pubsub

i started pubsub with command:

gcloud beta emulators pubsub start

And tried to create a topic with this code:
i put this code:

public class PubSubTest {

	public static void main(String[] args) throws InterruptedException, ExecutionException, URISyntaxException, IOException{

		Pubsub pubsub = Pubsub.builder().uri(new URI("http://localhost:8085/v1/")).credential(GoogleCredential.getApplicationDefault()).build();
		Topic topic = pubsub.createTopic("project", "the-topic").join();

	}

}

But it return this error:


Exception in thread "main" 11:24:31.932 [New I/O worker #1] DEBUG com.ning.http.client.providers.netty.channel.ChannelManager - Adding key: http://localhost:8085 for channel [id: 0x1cf05dc3, /127.0.0.1:59374 => localhost/127.0.0.1:8085]
java.util.concurrent.CompletionException: com.spotify.google.cloud.pubsub.client.RequestFailedException: 400 Bad Request
	at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:2303)
	at com.miei.test.PubSubTest.main(PubSubTest.java:21)
Caused by: com.spotify.google.cloud.pubsub.client.RequestFailedException: 400 Bad Request
	at com.spotify.google.cloud.pubsub.client.Pubsub$1.onStatusReceived(Pubsub.java:802)
	at com.ning.http.client.providers.netty.handler.HttpProtocol.exitAfterHandlingStatus(HttpProtocol.java:372)
	at com.ning.http.client.providers.netty.handler.HttpProtocol.handleHttpResponse(HttpProtocol.java:429)
	at com.ning.http.client.providers.netty.handler.HttpProtocol.handle(HttpProtocol.java:470)
	at com.ning.http.client.providers.netty.handler.Processor.messageReceived(Processor.java:88)
	at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
	at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
	at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
	at org.jboss.netty.handler.stream.ChunkedWriteHandler.handleUpstream(ChunkedWriteHandler.java:142)
	at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
	at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
	at org.jboss.netty.handler.codec.http.HttpContentDecoder.messageReceived(HttpContentDecoder.java:108)
	at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
	at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
	at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
	at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:459)
	at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:536)
	at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:435)
	at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
	at org.jboss.netty.handler.codec.http.HttpClientCodec.handleUpstream(HttpClientCodec.java:92)
	at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
	at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
	at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
	at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
	at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
	at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
	at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
	at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
	at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

On gcloud console i found this error:

[pubsub] This is the Google Pub/Sub fake.
[pubsub] Implementation may be incomplete or differ from the real system.
[pubsub] giu 09, 2017 11:22:38 AM com.google.cloud.pubsub.testing.v1.Main main
[pubsub] INFORMAZIONI: IAM integration is disabled. IAM policy methods and ACL checks are not supported
[pubsub] giu 09, 2017 11:22:38 AM io.grpc.internal.ManagedChannelImpl <init>
[pubsub] INFORMAZIONI: [ManagedChannelImpl@4a891e7e] Created with target localhost:8085
[pubsub] giu 09, 2017 11:22:38 AM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround
[pubsub] INFORMAZIONI: Unable to apply Java 7 long hostname workaround.
[pubsub] giu 09, 2017 11:22:38 AM com.google.cloud.pubsub.testing.v1.Main main
[pubsub] INFORMAZIONI: Server started, listening on 8085
[pubsub] giu 09, 2017 11:24:06 AM io.gapi.emulators.grpc.GrpcServer$3 operationComplete
[pubsub] INFORMAZIONI: Adding handler(s) to newly registered Channel.
[pubsub] giu 09, 2017 11:24:06 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
[pubsub] INFORMAZIONI: Detected non-HTTP/2 connection.
[pubsub] giu 09, 2017 11:24:06 AM io.gapi.emulators.grpc.HttpAdapter$UnaryMethodHandler handle
[pubsub] AVVERTENZA: Failed to convert request to message: Field google.pubsub.v1.Topic.name has already been set.
[pubsub] com.google.protobuf.InvalidProtocolBufferException: Field google.pubsub.v1.Topic.name has already been set.
[pubsub] 	at io.gapi.emulators.grpc.JsonFormat$ParserImpl.mergeField(JsonFormat.java:1383)
[pubsub] 	at io.gapi.emulators.grpc.JsonFormat$ParserImpl.mergeMessage(JsonFormat.java:1239)
[pubsub] 	at io.gapi.emulators.grpc.JsonFormat$ParserImpl.merge(JsonFormat.java:1197)
[pubsub] 	at io.gapi.emulators.grpc.JsonFormat$ParserImpl.merge(JsonFormat.java:1079)
[pubsub] 	at io.gapi.emulators.grpc.JsonFormat$Parser.merge(JsonFormat.java:283)
[pubsub] 	at io.gapi.emulators.grpc.HttpJsonAdapter.merge(HttpJsonAdapter.java:61)
[pubsub] 	at io.gapi.emulators.grpc.HttpAdapter$UnaryMethodHandler.handle(HttpAdapter.java:466)
[pubsub] 	at io.gapi.emulators.grpc.HttpAdapter.handleRequest(HttpAdapter.java:165)
[pubsub] 	at io.gapi.emulators.netty.HttpHandler.channelRead(HttpHandler.java:52)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
[pubsub] 	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
[pubsub] 	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
[pubsub] 	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
[pubsub] 	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:39)
[pubsub] 	at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:364)
[pubsub] 	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
[pubsub] 	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:418)
[pubsub] 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:454)
[pubsub] 	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873)
[pubsub] 	at java.lang.Thread.run(Thread.java:745)
[pubsub]
[pubsub] giu 09, 2017 11:24:06 AM io.gapi.emulators.netty.HttpHandler$1 onError
[pubsub] INFORMAZIONI: Exception when handling request: INVALID_ARGUMENT: Payload isn't valid for request.

i've also tried to create the topic with a curl -XPUT http://localhost:8085/v1/projects/project/topics/the-topic and topic is correctly created

Debugging i've found that "put" request "com.spotify.google.cloud.pubsub.client.Pubsub.request(String, HttpMethod, String, Class, Object)" for a topic creation sends a payload that is different from "NO_PAYLOAD" , so i've tried to change runtime value of payload param to "NO_PAYLOAD" and with this configuration topic creation works perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant