You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/01/10 07:54:10 UTC

[GitHub] [servicecomb-service-center] Shonminh opened a new issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Shonminh opened a new issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620
 
 
   **Describe the bug**
   A clear and concise description of what the bug is.
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. 向service center 注册了一个服务,service_idm是43e78d76cc47a565fcdab0c5e4fe7c5be7166ff4
   ![image](https://user-images.githubusercontent.com/7269690/72135216-e7910600-33c0-11ea-8f96-44281cb0ecee.png)
   
   2. 借助wscat(一个命令行 websocket 客户端)请求watcher接口:
   ```shell
   wscat -c "ws://localhost:30100/v4/default/registry/microservices/43e78d76cc47a565fcdab0c5e4fe7c5be7166ff4/listwatcher" -H "X-Domain-Name: default"
   ```
   3. 关掉注册的服务实例,观察wscat客户端
   
   4. 重启服务,观察wscat客户端。
   
   **Expected behavior**
   A clear and concise description of what you expected to happen.
   能够收到响应:
   ![image](https://user-images.githubusercontent.com/7269690/72135252-fe375d00-33c0-11ea-8ade-5acb17dc727f.png)
   
   **Platform And Runtime (please complete the following information):**
   只有websocket的ping/pong,无任何服务的变更信息。
   Platform
    - OS: Mac OS
    - Browser [e.g. chrome, safari]
    - Version [e.g. 22]
   
   Runtime
    - Version go 1.12
   
   **Additional context**
   Add any other context about the problem here.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] tianxiaoliang commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-574941415
 
 
   ok,会看下

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] goldbeef edited a comment on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
goldbeef edited a comment on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-572928016
 
 
   > 这是两个流程:
   > 1、服务消费方,会调用/v4/{project}/registry/instances?appId=&serviceName=&version=0+发现提供方的实例信息,进行接口调用,此时服务中心会记录他们之间的调用关系
   > 2、消费方注册成功后,使用注册得到的微服务ID进行watch,此后只要提供方实例发生变化都会感知到
   
   我们就是通过上面2, 来watch, 但是感知不到事件,但是websocket是联通。
   
   服务注册方
   ```go
   func main()  {
   	registryClient := &client.RegistryClient{}
   
   	err := registryClient.Initialize(
   		client.Options{
   			Addrs: []string{"127.0.0.1:30100"},
   		})
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	/*
   	"myapp1.1", "myserver1", "0.0.1", "")
   	*/
   	service := &proto.MicroService{
   		AppId: "myapp1.1",
   		ServiceName:"myserver1",
   		Version: "0.0.1",
   		Environment: "",
   	}
   
   	ctx := context.Background()
   	sid ,err := registryClient.RegisterService(ctx, service)
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   	fmt.Printf("sid[%v]\n", sid)
   
   	instance := proto.MicroServiceInstance{
   		ServiceId: sid,
   		HostName: "insdfsdsdfsdff2",
   		Status: common.DefaultStatus,
   		Endpoints: []string{"10.146.207.197:8080"},
   		Properties: map[string]string{
   			"Name": "12",
   		},
   	}
   
   	iid, err := registryClient.RegisterMicroServiceInstance(ctx, &instance)
   	if err != nil {
   		fmt.Printf("RegisterMicroServiceInstance, err[%v]\n", err)
   		os.Exit(1)
   	}
   
   
   	//registryClient.WatchMicroService(sid, printEvent)
   	cnt := 0
   	for ; ;  {
   		//registryClient.Heartbeat(ctx, sid, iid)
   		cnt++
   
   		status := ""
   		if cnt % 2 == 0 {
   			status = common.DefaultStatus
   		} else {
   			status = "DOWN"
   		}
   
   		_, err := registryClient.UpdateMicroServiceInstanceStatus(context.Background(), sid, iid, status)
   		if err != nil {
   			fmt.Printf("UpdateMicroServiceInstanceStatus, err[%v]\n", err)
   		}
   		time.Sleep(time.Second)
   	}
   
   	registryClient.UnregisterMicroServiceInstance(ctx, sid, iid)
   
   	fmt.Printf("sid[%v], iid[%v]\n", sid, iid)
   }
   
   func printEvent(event *client.MicroServiceInstanceChangedEvent) {
   	content, _ := json.Marshal(event)
   	fmt.Printf("event[%v]\n", string(content))
   }
   ```
   
   服务发现方:
   ```
   func main()  {
   	registryClient := &client.RegistryClient{}
   
   	err := registryClient.Initialize(
   		client.Options{
   			Addrs: []string{"127.0.0.1:30100"},
   		})
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	ctx := context.Background()
   	sid, err := registryClient.GetMicroServiceID(ctx, "myapp1.1", "myserver1", "0.0.1", "")
   	if err != nil {
   		fmt.Printf("GetMicroServiceID, err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	if sid == "" {
   		fmt.Printf("sid[%v], empty\n", sid)
   		os.Exit(1)
   	}
   
   	/*
   	for ; ;  {
   		instance, err := registryClient.GetMicroServiceInstances(ctx, "", sid)
   		if err != nil {
   			fmt.Printf("GetMicroServiceID, err[%v]\n", err)
   			os.Exit(1)
   		}
   
   		content, _ := json.Marshal(instance)
   		fmt.Printf("content[%v]\n", string(content))
   		time.Sleep(time.Second)
   	}*/
   
   	for ; ;  {
   		err = registryClient.WatchMicroService(sid, printEvent)
   		if err != nil {
   			log.Panicf("WatchMicroService, err[%v]", err)
   		}
   		time.Sleep(time.Second)
   	}
   }
   
   func printEvent(event *client.MicroServiceInstanceChangedEvent) {
   	content, _ := json.Marshal(event)
   	fmt.Printf("event[%v]\n", string(content))
   }
   ```
   
   ![image](https://user-images.githubusercontent.com/5627680/72137751-5886ec80-33c6-11ea-9e4b-a3b613a772b3.png)
   ![image](https://user-images.githubusercontent.com/5627680/72137775-62a8eb00-33c6-11ea-8bee-1dbd60480461.png)
   
   ![image](https://user-images.githubusercontent.com/5627680/72137868-92f08980-33c6-11ea-9895-d7945b5ce2c7.png)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] tianxiaoliang edited a comment on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
tianxiaoliang edited a comment on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-574946635
 
 
   默认不允许跨app访问,把注册的app改为一致即可
   
   sc的这约束我也不是很喜欢,不过接口不可轻易变更啊,所以一直就没有改
   
   在go chassis端,我做了规避,给用户更好的体验
   
   ```go
   // GetRegistratorScope returns the Scope of service registry
   func GetRegistratorScope() string {
   	if GlobalDefinition.Cse.Service.Registry.Registrator.Scope == "" {
   		GlobalDefinition.Cse.Service.Registry.Registrator.Scope = common.ScopeFull
   	}
   	return GlobalDefinition.Cse.Service.Registry.Scope
   }
   ```
   
   
   ```go
   if config.GetRegistratorScope() == common.ScopeFull {
   	microservice.Metadata["allowCrossApp"] = common.TRUE
   	service.ServiceDescription.Properties["allowCrossApp"] = common.TRUE
   } else {
   	service.ServiceDescription.Properties["allowCrossApp"] = common.FALSE
   }
   ```
   
   可以看出go chassis处理时 默认不配置就可以允许跨app访问了。
   
   可否对我们的service center文档进行些完善说明@little-cui 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] goldbeef commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
goldbeef commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-572928016
 
 
   
   
   > 这是两个流程:
   > 1、服务消费方,会调用/v4/{project}/registry/instances?appId=&serviceName=&version=0+发现提供方的实例信息,进行接口调用,此时服务中心会记录他们之间的调用关系
   > 2、消费方注册成功后,使用注册得到的微服务ID进行watch,此后只要提供方实例发生变化都会感知到
   
   我们就是通过上面2, 来watch, 但是感知不到事件,但是websocket是联通。
   
   服务注册方
   `
   func main()  {
   	registryClient := &client.RegistryClient{}
   
   	err := registryClient.Initialize(
   		client.Options{
   			Addrs: []string{"127.0.0.1:30100"},
   		})
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	/*
   	"myapp1.1", "myserver1", "0.0.1", "")
   	*/
   	service := &proto.MicroService{
   		AppId: "myapp1.1",
   		ServiceName:"myserver1",
   		Version: "0.0.1",
   		Environment: "",
   	}
   
   	ctx := context.Background()
   	sid ,err := registryClient.RegisterService(ctx, service)
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   	fmt.Printf("sid[%v]\n", sid)
   
   	instance := proto.MicroServiceInstance{
   		ServiceId: sid,
   		HostName: "insdfsdsdfsdff2",
   		Status: common.DefaultStatus,
   		Endpoints: []string{"10.146.207.197:8080"},
   		Properties: map[string]string{
   			"Name": "12",
   		},
   	}
   
   	iid, err := registryClient.RegisterMicroServiceInstance(ctx, &instance)
   	if err != nil {
   		fmt.Printf("RegisterMicroServiceInstance, err[%v]\n", err)
   		os.Exit(1)
   	}
   
   
   	//registryClient.WatchMicroService(sid, printEvent)
   	cnt := 0
   	for ; ;  {
   		//registryClient.Heartbeat(ctx, sid, iid)
   		cnt++
   
   		status := ""
   		if cnt % 2 == 0 {
   			status = common.DefaultStatus
   		} else {
   			status = "DOWN"
   		}
   
   		_, err := registryClient.UpdateMicroServiceInstanceStatus(context.Background(), sid, iid, status)
   		if err != nil {
   			fmt.Printf("UpdateMicroServiceInstanceStatus, err[%v]\n", err)
   		}
   		time.Sleep(time.Second)
   	}
   
   	registryClient.UnregisterMicroServiceInstance(ctx, sid, iid)
   
   	fmt.Printf("sid[%v], iid[%v]\n", sid, iid)
   }
   
   func printEvent(event *client.MicroServiceInstanceChangedEvent) {
   	content, _ := json.Marshal(event)
   	fmt.Printf("event[%v]\n", string(content))
   }
   
   `
   
   服务发现方:
   `
   func main()  {
   	registryClient := &client.RegistryClient{}
   
   	err := registryClient.Initialize(
   		client.Options{
   			Addrs: []string{"127.0.0.1:30100"},
   		})
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	ctx := context.Background()
   	sid, err := registryClient.GetMicroServiceID(ctx, "myapp1.1", "myserver1", "0.0.1", "")
   	if err != nil {
   		fmt.Printf("GetMicroServiceID, err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	if sid == "" {
   		fmt.Printf("sid[%v], empty\n", sid)
   		os.Exit(1)
   	}
   
   	/*
   	for ; ;  {
   		instance, err := registryClient.GetMicroServiceInstances(ctx, "", sid)
   		if err != nil {
   			fmt.Printf("GetMicroServiceID, err[%v]\n", err)
   			os.Exit(1)
   		}
   
   		content, _ := json.Marshal(instance)
   		fmt.Printf("content[%v]\n", string(content))
   		time.Sleep(time.Second)
   	}*/
   
   	for ; ;  {
   		err = registryClient.WatchMicroService(sid, printEvent)
   		if err != nil {
   			log.Panicf("WatchMicroService, err[%v]", err)
   		}
   		time.Sleep(time.Second)
   	}
   }
   
   func printEvent(event *client.MicroServiceInstanceChangedEvent) {
   	content, _ := json.Marshal(event)
   	fmt.Printf("event[%v]\n", string(content))
   }
   `
   
   ![image](https://user-images.githubusercontent.com/5627680/72137751-5886ec80-33c6-11ea-9e4b-a3b613a772b3.png)
   ![image](https://user-images.githubusercontent.com/5627680/72137775-62a8eb00-33c6-11ea-8bee-1dbd60480461.png)
   
   ![image](https://user-images.githubusercontent.com/5627680/72137868-92f08980-33c6-11ea-9895-d7945b5ce2c7.png)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] goldbeef commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
goldbeef commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-574543009
 
 
   @tianxiaoliang , 可以帮忙看下上面问题吗?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] little-cui commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
little-cui commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-572925518
 
 
   这是两个流程:
   1、服务消费方,会调用/v4/{project}/registry/instances?appId=&serviceName=&version=0+发现提供方的实例信息,进行接口调用,此时服务中心会记录他们之间的调用关系
   2、消费方注册成功后,使用注册得到的微服务ID进行watch,此后只要提供方实例发生变化都会感知到

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] Shonminh commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
Shonminh commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-572922810
 
 
   那么在使用watcher接口的时候,如何指定我需要关心的服务提供者?是需要配置dependency吗?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] goldbeef commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
goldbeef commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-573490329
 
 
   > err = registryClient.WatchMicroService(sid, printEvent)这里错了,sid应该是服务发现方的id,此时你只需要把服务发现方注册上去就可以了。另外,应该使用FindMicroServiceInstances来获取服务注册方的信息
   
   @little-cui   刚才尝试了下,还是不行
   
   注册方:
   ```go
   func main()  {
   	registryClient := &client.RegistryClient{}
   
   	err := registryClient.Initialize(
   		client.Options{
   			Addrs: []string{"127.0.0.1:30100"},
   		})
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	/*
   	"myapp1.1", "myserver1", "0.0.1", "")
   	*/
   	service := &proto.MicroService{
   		AppId: "myapp1.1",
   		ServiceName:"myserver1",
   		Version: "0.0.1",
   		Environment: "",
   	}
   
   	ctx := context.Background()
   	sid ,err := registryClient.RegisterService(ctx, service)
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   	fmt.Printf("sid[%v]\n", sid)
   
   	instance := proto.MicroServiceInstance{
   		ServiceId: sid,
   		HostName: "insdfsdsdfsdff223",
   		Status: common.DefaultStatus,
   		Endpoints: []string{"10.146.207.197:808"},
   		Properties: map[string]string{
   			"Name": "12",
   		},
   	}
   
   	iid, err := registryClient.RegisterMicroServiceInstance(ctx, &instance)
   	if err != nil {
   		fmt.Printf("RegisterMicroServiceInstance, err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	count := 0
   	for ; ;  {
   		count++
   		if count == 10 {
   			break
   		}
   		time.Sleep(time.Second)
   	}
   
   	/*
   	cnt := 0
   	for ; ;  {
   		cnt++
   
   		status := ""
   		if cnt % 2 == 0 {
   			status = common.DefaultStatus
   		} else {
   			status = "DOWN"
   		}
   
   		_, err := registryClient.UpdateMicroServiceInstanceStatus(context.Background(), sid, iid, status)
   		if err != nil {
   			fmt.Printf("UpdateMicroServiceInstanceStatus, err[%v]\n", err)
   		}
   		time.Sleep(time.Second)
   	}
   	*/
   
   	registryClient.UnregisterMicroServiceInstance(ctx, sid, iid)
   
   	fmt.Printf("sid[%v], iid[%v]\n", sid, iid)
   }
   ```
   
   发现方:
   ```go
   func main()  {
   	registryClient := &client.RegistryClient{}
   
   	err := registryClient.Initialize(
   		client.Options{
   			Addrs: []string{"127.0.0.1:30100"},
   		})
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	ctx := context.Background()
   	disService := &proto.MicroService{
   		AppId: "dismyapp1.1",
   		ServiceName:"dismyserver1",
   		Version: "0.0.1",
   		Environment: "",
   	}
   	disSid ,err := registryClient.RegisterService(ctx, disService)
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   	fmt.Printf("sid[%v]\n", disSid)
   
   	err = registryClient.WatchMicroService(disSid, printEvent)
   	if err != nil {
   		log.Panicf("WatchMicroService, err[%v]", err)
   	}
   
   	/*
   	for ; ;  {
   		instance, err := registryClient.GetMicroServiceInstances(ctx, "", sid)
   		if err != nil {
   			fmt.Printf("GetMicroServiceID, err[%v]\n", err)
   			os.Exit(1)
   		}
   
   		content, _ := json.Marshal(instance)
   		fmt.Printf("content[%v]\n", string(content))
   		time.Sleep(time.Second)
   	}*/
   
   	for ; ;  {
   		instances, err := registryClient.FindMicroServiceInstances(ctx, disSid, "myapp1.1", "myserver1", "0.0.1")
   		fmt.Printf("instances[%v], err[%v]\n", instances, err)
   		time.Sleep(time.Second)
   	}
   }
   
   func printEvent(event *client.MicroServiceInstanceChangedEvent) {
   	content, _ := json.Marshal(event)
   	fmt.Printf("event[%v]\n", string(content))
   }
   ```
   
   有对注册方进行regist/unregist, 发现方的输出:
   ![image](https://user-images.githubusercontent.com/5627680/72230621-adf31180-35f1-11ea-9bdf-d70614e00da6.png)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] goldbeef edited a comment on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
goldbeef edited a comment on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-572928016
 
 
   
   > 这是两个流程:
   > 1、服务消费方,会调用/v4/{project}/registry/instances?appId=&serviceName=&version=0+发现提供方的实例信息,进行接口调用,此时服务中心会记录他们之间的调用关系
   > 2、消费方注册成功后,使用注册得到的微服务ID进行watch,此后只要提供方实例发生变化都会感知到
   
   我们就是通过上面2, 来watch, 但是感知不到事件,但是websocket是联通。
   
   服务注册方
   `func main()  {
   	registryClient := &client.RegistryClient{}
   
   	err := registryClient.Initialize(
   		client.Options{
   			Addrs: []string{"127.0.0.1:30100"},
   		})
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	/*
   	"myapp1.1", "myserver1", "0.0.1", "")
   	*/
   	service := &proto.MicroService{
   		AppId: "myapp1.1",
   		ServiceName:"myserver1",
   		Version: "0.0.1",
   		Environment: "",
   	}
   
   	ctx := context.Background()
   	sid ,err := registryClient.RegisterService(ctx, service)
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   	fmt.Printf("sid[%v]\n", sid)
   
   	instance := proto.MicroServiceInstance{
   		ServiceId: sid,
   		HostName: "insdfsdsdfsdff2",
   		Status: common.DefaultStatus,
   		Endpoints: []string{"10.146.207.197:8080"},
   		Properties: map[string]string{
   			"Name": "12",
   		},
   	}
   
   	iid, err := registryClient.RegisterMicroServiceInstance(ctx, &instance)
   	if err != nil {
   		fmt.Printf("RegisterMicroServiceInstance, err[%v]\n", err)
   		os.Exit(1)
   	}
   
   
   	//registryClient.WatchMicroService(sid, printEvent)
   	cnt := 0
   	for ; ;  {
   		//registryClient.Heartbeat(ctx, sid, iid)
   		cnt++
   
   		status := ""
   		if cnt % 2 == 0 {
   			status = common.DefaultStatus
   		} else {
   			status = "DOWN"
   		}
   
   		_, err := registryClient.UpdateMicroServiceInstanceStatus(context.Background(), sid, iid, status)
   		if err != nil {
   			fmt.Printf("UpdateMicroServiceInstanceStatus, err[%v]\n", err)
   		}
   		time.Sleep(time.Second)
   	}
   
   	registryClient.UnregisterMicroServiceInstance(ctx, sid, iid)
   
   	fmt.Printf("sid[%v], iid[%v]\n", sid, iid)
   }
   
   func printEvent(event *client.MicroServiceInstanceChangedEvent) {
   	content, _ := json.Marshal(event)
   	fmt.Printf("event[%v]\n", string(content))
   }`
   
   服务发现方:`
   func main()  {
   	registryClient := &client.RegistryClient{}
   
   	err := registryClient.Initialize(
   		client.Options{
   			Addrs: []string{"127.0.0.1:30100"},
   		})
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	ctx := context.Background()
   	sid, err := registryClient.GetMicroServiceID(ctx, "myapp1.1", "myserver1", "0.0.1", "")
   	if err != nil {
   		fmt.Printf("GetMicroServiceID, err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	if sid == "" {
   		fmt.Printf("sid[%v], empty\n", sid)
   		os.Exit(1)
   	}
   
   	/*
   	for ; ;  {
   		instance, err := registryClient.GetMicroServiceInstances(ctx, "", sid)
   		if err != nil {
   			fmt.Printf("GetMicroServiceID, err[%v]\n", err)
   			os.Exit(1)
   		}
   
   		content, _ := json.Marshal(instance)
   		fmt.Printf("content[%v]\n", string(content))
   		time.Sleep(time.Second)
   	}*/
   
   	for ; ;  {
   		err = registryClient.WatchMicroService(sid, printEvent)
   		if err != nil {
   			log.Panicf("WatchMicroService, err[%v]", err)
   		}
   		time.Sleep(time.Second)
   	}
   }
   
   func printEvent(event *client.MicroServiceInstanceChangedEvent) {
   	content, _ := json.Marshal(event)
   	fmt.Printf("event[%v]\n", string(content))
   }`
   
   ![image](https://user-images.githubusercontent.com/5627680/72137751-5886ec80-33c6-11ea-9e4b-a3b613a772b3.png)
   ![image](https://user-images.githubusercontent.com/5627680/72137775-62a8eb00-33c6-11ea-8bee-1dbd60480461.png)
   
   ![image](https://user-images.githubusercontent.com/5627680/72137868-92f08980-33c6-11ea-9895-d7945b5ce2c7.png)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] little-cui commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
little-cui commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-572921665
 
 
   这两个接口的区别仅仅在于首次watch服务中心时listwatch会返回服务消费方关心的全量实例信息。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] little-cui commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
little-cui commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-572929947
 
 
   err = registryClient.WatchMicroService(sid, printEvent)这里错了,sid应该是服务发现方的id,此时你只需要把服务发现方注册上去就可以了。另外,应该使用FindMicroServiceInstances来获取服务注册方的信息

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] goldbeef commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
goldbeef commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-574973378
 
 
   > o chassis example目录下,叫watcher,做个简单的readme说明例子展示的能力
   
   ok。  刚才验证了下,appid一样的话,没有问题。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] goldbeef edited a comment on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
goldbeef edited a comment on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-572928016
 
 
   > 这是两个流程:
   > 1、服务消费方,会调用/v4/{project}/registry/instances?appId=&serviceName=&version=0+发现提供方的实例信息,进行接口调用,此时服务中心会记录他们之间的调用关系
   > 2、消费方注册成功后,使用注册得到的微服务ID进行watch,此后只要提供方实例发生变化都会感知到
   
   我们就是通过上面2, 来watch, 但是感知不到事件,但是websocket是联通。
   
   服务注册方
   ```go
   func main()  {
   	registryClient := &client.RegistryClient{}
   
   	err := registryClient.Initialize(
   		client.Options{
   			Addrs: []string{"127.0.0.1:30100"},
   		})
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	/*
   	"myapp1.1", "myserver1", "0.0.1", "")
   	*/
   	service := &proto.MicroService{
   		AppId: "myapp1.1",
   		ServiceName:"myserver1",
   		Version: "0.0.1",
   		Environment: "",
   	}
   
   	ctx := context.Background()
   	sid ,err := registryClient.RegisterService(ctx, service)
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   	fmt.Printf("sid[%v]\n", sid)
   
   	instance := proto.MicroServiceInstance{
   		ServiceId: sid,
   		HostName: "insdfsdsdfsdff2",
   		Status: common.DefaultStatus,
   		Endpoints: []string{"10.146.207.197:8080"},
   		Properties: map[string]string{
   			"Name": "12",
   		},
   	}
   
   	iid, err := registryClient.RegisterMicroServiceInstance(ctx, &instance)
   	if err != nil {
   		fmt.Printf("RegisterMicroServiceInstance, err[%v]\n", err)
   		os.Exit(1)
   	}
   
   
   	//registryClient.WatchMicroService(sid, printEvent)
   	cnt := 0
   	for ; ;  {
   		//registryClient.Heartbeat(ctx, sid, iid)
   		cnt++
   
   		status := ""
   		if cnt % 2 == 0 {
   			status = common.DefaultStatus
   		} else {
   			status = "DOWN"
   		}
   
   		_, err := registryClient.UpdateMicroServiceInstanceStatus(context.Background(), sid, iid, status)
   		if err != nil {
   			fmt.Printf("UpdateMicroServiceInstanceStatus, err[%v]\n", err)
   		}
   		time.Sleep(time.Second)
   	}
   
   	registryClient.UnregisterMicroServiceInstance(ctx, sid, iid)
   
   	fmt.Printf("sid[%v], iid[%v]\n", sid, iid)
   }
   
   func printEvent(event *client.MicroServiceInstanceChangedEvent) {
   	content, _ := json.Marshal(event)
   	fmt.Printf("event[%v]\n", string(content))
   }
   ```
   
   服务发现方:
   ```go
   func main()  {
   	registryClient := &client.RegistryClient{}
   
   	err := registryClient.Initialize(
   		client.Options{
   			Addrs: []string{"127.0.0.1:30100"},
   		})
   	if err != nil {
   		fmt.Printf("err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	ctx := context.Background()
   	sid, err := registryClient.GetMicroServiceID(ctx, "myapp1.1", "myserver1", "0.0.1", "")
   	if err != nil {
   		fmt.Printf("GetMicroServiceID, err[%v]\n", err)
   		os.Exit(1)
   	}
   
   	if sid == "" {
   		fmt.Printf("sid[%v], empty\n", sid)
   		os.Exit(1)
   	}
   
   	/*
   	for ; ;  {
   		instance, err := registryClient.GetMicroServiceInstances(ctx, "", sid)
   		if err != nil {
   			fmt.Printf("GetMicroServiceID, err[%v]\n", err)
   			os.Exit(1)
   		}
   
   		content, _ := json.Marshal(instance)
   		fmt.Printf("content[%v]\n", string(content))
   		time.Sleep(time.Second)
   	}*/
   
   	for ; ;  {
   		err = registryClient.WatchMicroService(sid, printEvent)
   		if err != nil {
   			log.Panicf("WatchMicroService, err[%v]", err)
   		}
   		time.Sleep(time.Second)
   	}
   }
   
   func printEvent(event *client.MicroServiceInstanceChangedEvent) {
   	content, _ := json.Marshal(event)
   	fmt.Printf("event[%v]\n", string(content))
   }
   ```
   
   ![image](https://user-images.githubusercontent.com/5627680/72137751-5886ec80-33c6-11ea-9e4b-a3b613a772b3.png)
   ![image](https://user-images.githubusercontent.com/5627680/72137775-62a8eb00-33c6-11ea-8bee-1dbd60480461.png)
   
   ![image](https://user-images.githubusercontent.com/5627680/72137868-92f08980-33c6-11ea-9895-d7945b5ce2c7.png)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] Shonminh commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
Shonminh commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-572921089
 
 
   1. 这个issue写的是watcher的接口的,但是其实我也试了listwatcher接口.
   2. 我填的是提供方的 serviceId。原来需要填消费者的,那么这两接口会监听到所有的服务变更?需要我自己在客户过滤提供方?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] tianxiaoliang commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-574946635
 
 
   默认不允许跨app访问,把注册的app改为一致即可
   
   sc的这约束我也不是很喜欢,不过接口不可轻易变更啊,所以一直就没有改
   
   在go chassis端,我做了规避,给用户更好的体验
   
   ```go
   // GetRegistratorScope returns the Scope of service registry
   func GetRegistratorScope() string {
   	if GlobalDefinition.Cse.Service.Registry.Registrator.Scope == "" {
   		GlobalDefinition.Cse.Service.Registry.Registrator.Scope = common.ScopeFull
   	}
   	return GlobalDefinition.Cse.Service.Registry.Scope
   }
   ```
   
   ```go
   	if config.GetRegistratorScope() == common.ScopeFull {
   		microservice.Metadata["allowCrossApp"] = common.TRUE
   		service.ServiceDescription.Properties["allowCrossApp"] = common.TRUE
   	} else {
   		service.ServiceDescription.Properties["allowCrossApp"] = common.FALSE
   	}
   ```
   
   可以看出go chassis处理时 默认不配置就可以允许跨app访问了。
   
   可否对我们的service center文档进行些完善说明@little-cui 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] tianxiaoliang commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-574947282
 
 
   @goldbeef 可否将更正后的代码贡献到go chassis example目录下,叫watcher,做个简单的readme说明例子展示的能力

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] tianxiaoliang edited a comment on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
tianxiaoliang edited a comment on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-574946635
 
 
   默认不允许跨app访问,把注册的app改为一致即可
   
   sc的这约束我也不是很喜欢,不过接口不可轻易变更啊,所以一直就没有改
   
   在go chassis端,我做了规避,给用户更好的体验
   
   ```go
   // GetRegistratorScope returns the Scope of service registry
   func GetRegistratorScope() string {
   	if GlobalDefinition.Cse.Service.Registry.Registrator.Scope == "" {
   		GlobalDefinition.Cse.Service.Registry.Registrator.Scope = common.ScopeFull
   	}
   	return GlobalDefinition.Cse.Service.Registry.Scope
   }
   ```
   
   
   ```go
   	if config.GetRegistratorScope() == common.ScopeFull {
   		microservice.Metadata["allowCrossApp"] = common.TRUE
   		service.ServiceDescription.Properties["allowCrossApp"] = common.TRUE
   	} else {
   		service.ServiceDescription.Properties["allowCrossApp"] = common.FALSE
   	}
   ```
   
   可以看出go chassis处理时 默认不配置就可以允许跨app访问了。
   
   可否对我们的service center文档进行些完善说明@little-cui 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] little-cui commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
little-cui commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-572917960
 
 
   确认下你调用的是watcher接口还是listwatcher?
   注意:watch接口的path参数为消费方微服务ID,而不是服务提供方RPCServer的微服务ID,除非RPCServer消费自身API

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-service-center] goldbeef commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包

Posted by GitBox <gi...@apache.org>.
goldbeef commented on issue #620: 使用/v4/{project}/registry/microservices/{serviceId}/watcher无法收到回包
URL: https://github.com/apache/servicecomb-service-center/issues/620#issuecomment-573485297
 
 
   > err = registryClient.WatchMicroService(sid, printEvent)这里错了,sid应该是服务发现方的id,此时你只需要把服务发现方注册上去就可以了。另外,应该使用FindMicroServiceInstances来获取服务注册方的信息
   
   ok, 多谢。我尝试下

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services