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

Error when creating EvenHub services with python sdk #32

Open
hpujana opened this issue Apr 12, 2018 · 7 comments
Open

Error when creating EvenHub services with python sdk #32

hpujana opened this issue Apr 12, 2018 · 7 comments

Comments

@hpujana
Copy link

hpujana commented Apr 12, 2018

I tried to create EventHub services using python SDK. This is the code:

import predix.admin.app

admin = predix.admin.app.Manifest()

admin.create_eventhub(publish=True, subscribe=True)

However I have the following error:

hon init_eventhub.py WARNING:root:Writing manifest manifest.yml unencrypted. Traceback (most recent call last): File "init_eventhub.py", line 5, in admin.create_eventhub(publish=True, subscribe=True) File "C:\Python27\lib\site-packages\predix\admin\app.py", line 214, in create eventhub eventhub = predix.admin.eventhub.EventHub(**kwargs) AttributeError: 'module' object has no attribute 'eventhub'

@hpujana hpujana changed the title rror when creating EvenHub services with python sdk Error when creating EvenHub services with python sdk Apr 12, 2018
@hpujana
Copy link
Author

hpujana commented Apr 12, 2018

It looks like it is missing the following line in /predix/admin/app.py

import predix.admin.eventhub

But in this case I get the following error:

Traceback (most recent call last):
File "init_eventhub.py", line 5, in
admin.create_eventhub(publish=True, subscribe=True)
File "C:\Python27\lib\site-packages\predix\admin\app.py", line 215, in create_
eventhub
eventhub = predix.admin.eventhub.EventHub(**kwargs)
File "C:\Python27\lib\site-packages\predix\admin\eventhub.py", line 17, in i
nit

self.use_class = predix.data.eventhub.Eventhub
AttributeError: 'module' object has no attribute 'Eventhub'

@j12y
Copy link
Member

j12y commented Apr 12, 2018

Sorry you ran into that. Maybe something went wrong in the release @ThisWillGoWell?

@ThisWillGoWell
Copy link

Found error, working on solution and testing

@ThisWillGoWell
Copy link

fixed in #33

@hpujana
Copy link
Author

hpujana commented May 4, 2018

I use the code from '#33' as python SDK.

With it, I am able to create the EventHub service: This the code used (shared by William)

import predix.admin.app
import logging

logging.basicConfig(level=logging.INFO)

app = predix.admin.app.Manifest(app_name='aqua-monkey')
uaa = app.create_uaa('Chang3m3you', name='gepower-40-predixpy-example-uaa-service')

app.create_client('client', '7169', uaa=uaa)
app.create_eventhub(name='gepower-40-predixpy-example-eventhub-service',
uaa=uaa,
publish=True,
subscribe=True)

However I am not able to upload events to the EvenHub microservice

This is the code used

import time
import predix.app
from predix.data.eventhub.publisher import PublisherConfig

predix_app = predix.app.Manifest()

eh = predix_app.get_eventhub(
publish_config=PublisherConfig(
publish_type=PublisherConfig.Type.SYNC
)
)

count = 0
a = 0
while True:
print(a)
a = a + 1
message_id = "id-" + str(count)
acks = eh.publisher.add_message(message_id, str(count)).publish_queue()
print(acks)
count += 1
time.sleep(5)

## The result in the console is the following:

_WARNING:root:Writing manifest manifest.yml unencrypted.
Exception in thread Thread-4:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "C:\Python27\lib\threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "C:\Python27\lib\site-packages\predix\data\eventhub\grpc_manager.py", lin
e 49, in _grpc_rx_receiver
for m in msgs:
File "C:\Python27\lib\site-packages\grpc_channel.py", line 350, in next
return self._next()
File "C:\Python27\lib\site-packages\grpc_channel.py", line 341, in _next
raise self
_Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNKNOWN, Could
not authenticate request)>

0
[]
1
[]
2
[]
3_

**It looks like there is a problem when connect to the Evenhub Service.

After It looks like nothing is uploaded. When try to read from such Service no response is get.**

I use python 2.7

Is there any issue, or there is something i am not using in a correct way?

Any help would be appreciated

** this is the manifiest**


applications:

  • name: aqua-monkey
    env:
    PREDIXPY_VERSION: 1.0.0rc1
    PREDIX_APP_CLIENT_ID: client
    PREDIX_APP_CLIENT_SECRET: '7169'
    PREDIX_DATA_EVENTHUB_CLIENT_HOST: event-hub-aws-usw02.data-services.predix.io
    PREDIX_DATA_EVENTHUB_CLIENT_PORT: '443'
    PREDIX_DATA_EVENTHUB_CLIENT_WSS_PUBLISH_URI: wss://event-hub-aws-usw02.data-services.predix.io/v1/stream/messages/
    PREDIX_DATA_EVENTHUB_CLIENT_ZONE_ID: 9933e8c1-0333-4d60-bb04-21d102d6ba9d
    PREDIX_SECURITY_UAA_URI: https://e5e45aff-9c66-477a-8950-47fc54d25ad8.predix-uaa.run.aws-usw02-pr.ice.predix.io
    services:
  • gepower-40-predixpy-example-eventhub-service
  • gepower-40-predixpy-example-uaa-service

@ThisWillGoWell
Copy link

_Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNKNOWN, Could
not authenticate request)>
is returned from the service when the client credentials are incorrect. Can you check the uaa instance and validate the scopes were created correctly?

@hpujana
Copy link
Author

hpujana commented May 11, 2018

Hi:

The uaa scope seems to be correct:

"scope": "timeseries.zones.b3b38032-185a-4696-a99c-86efeabf46f5.query predix-event-hub.zones.320029a9-1388-4bce-b731-459dd3fd9d89.wss.publish uaa.resource timeseries.zones.b3b38032-185a-4696-a99c-86efeabf46f5.ingest predix-event-hub.zones.320029a9-1388-4bce-b731-459dd3fd9d89.grpc.subscribe predix-event-hub.zones.320029a9-1388-4bce-b731-459dd3fd9d89.grpc.publish predix-event-hub.zones.320029a9-1388-4bce-b731-459dd3fd9d89.topic.grpc.publish predix-event-hub.zones.320029a9-1388-4bce-b731-459dd3fd9d89.topic.user predix-event-hub.zones.320029a9-1388-4bce-b731-459dd3fd9d89.topic.grpc.subscribe timeseries.zones.b3b38032-185a-4696-a99c-86efeabf46f5.user uaa.none predix-event-hub.zones.320029a9-1388-4bce-b731-459dd3fd9d89.topic.wss.publish predix-event-hub.zones.320029a9-1388-4bce-b731-459dd3fd9d89.user",

I found that the error:

_Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNKNOWN, Could
not authenticate request)>

It is shown when I define "https_proxy" and "http_proxy" in the eviroment variables in windows.

Does the eventhub service allow the use of a proxy? If yes, what is the correct way to define it?

Anyway. even if I do not go through a proxy I am not able to upload variables:

The ACK returns [].

Best regards

I attache the manifest


applications:

  • name: aqua-monkey
    env:
    PREDIXPY_VERSION: 1.0.0rc1
    PREDIX_APP_CLIENT_ID: gepower
    PREDIX_APP_CLIENT_SECRET: '7169'
    PREDIX_DATA_EVENTHUB_CLIENT_HOST: event-hub-aws-usw02.data-services.predix.io
    PREDIX_DATA_EVENTHUB_CLIENT_PORT: '443'
    PREDIX_DATA_EVENTHUB_CLIENT_WSS_PUBLISH_URI: wss://event-hub-aws-usw02.data-services.predix.io/v1/stream/messages/
    PREDIX_DATA_EVENTHUB_CLIENT_ZONE_ID: 320029a9-1388-4bce-b731-459dd3fd9d89
    PREDIX_DATA_TIMESERIES_INGEST_URI: wss://gateway-predix-data-services.run.aws-usw02-pr.ice.predix.io/v1/stream/messages
    PREDIX_DATA_TIMESERIES_INGEST_ZONE_ID: b3b38032-185a-4696-a99c-86efeabf46f5
    PREDIX_DATA_TIMESERIES_QUERY_URI: https://time-series-store-predix.run.aws-usw02-pr.ice.predix.io
    PREDIX_DATA_TIMESERIES_QUERY_ZONE_ID: b3b38032-185a-4696-a99c-86efeabf46f5
    PREDIX_SECURITY_UAA_URI: https://aaf1b719-7db4-428e-88ce-e3c2bfba6e95.predix-uaa.run.aws-usw02-pr.ice.predix.io
    services:
  • dev-predix-uaa-free
  • dev-predix-timeseries-free
  • dev-predix-event-hub-tiered

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