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

连接失败 #2

Open
dravinbox opened this issue Feb 14, 2019 · 4 comments
Open

连接失败 #2

dravinbox opened this issue Feb 14, 2019 · 4 comments

Comments

@dravinbox
Copy link

dravinbox commented Feb 14, 2019

使用Go的sdk中的生产者代码,响应连接失败:
send request failed, the server closed connection before returning the first response byte. Make sure the server returns 'Connection: close' response header before closing the connection

package main

import (
	"fmt"
	"github.com/aliyunmq/mq-http-go-sdk"
	"time"
)

func main() {
	// 设置HTTP接入域名(此处以公共云生产环境为例)
	endpoint := "http://onsaddr.mq-internet-access.mq-internet.aliyuncs.com:80"
	// AccessKey 阿里云身份验证,在阿里云服务器管理控制台创建
	accessKey := "****************"
	// SecretKey 阿里云身份验证,在阿里云服务器管理控制台创建
	secretKey := "****************"
	// 所属的 Topic
	topic := "***********_test"
	// Topic所属实例ID,默认实例为空
	instanceId := "************yy7h2"

	client := mq_http_sdk.NewAliyunMQClient(endpoint, accessKey, secretKey, "")

	mqProducer := client.GetProducer(instanceId, topic)
	// 循环发送100条消息
	for i := 1; i < 100; i++ {
		msg := mq_http_sdk.PublishMessageRequest{
			MessageBody: "hello mq!", //消息内容
			MessageTag: "", // 消息标签
		}
		ret, err := mqProducer.PublishMessage(msg)

		if err != nil {
			fmt.Println(err)
			return
		} else {
			fmt.Printf("Publish ---->\n\tMessageId:%s, BodyMD5:%s, \n", ret.MessageId, ret.MessageBodyMD5)
		}
		time.Sleep(time.Duration(1) * time.Second)
	}
}
@wangming1993
Copy link

me too

@wangming1993
Copy link

wangming1993 commented Feb 25, 2019

@dravinbox 我解决了这个问题,:80 这个是 tcp 接入点的 endpoint, RockertMQ 现在只开放了 杭州节点的 http ,你需要在 华东1(杭州) 下面创建实例, 然后获取 http endpoint

@dravinbox
Copy link
Author

@dravinbox 我解决了这个问题,80 这个是 tcp tcp 接入点的 endpoint, RockertMQ 现在只开放了 杭州节点的 http ,你需要在 华东1(杭州) 下面创建实例, 然后获取 http endpoint

谢谢大佬,我这边不急,坐等深圳节点

@andotorg
Copy link

一句话总结,网络不通导致的问题

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

3 participants