com.twitter.hbc.core.Constants Java Examples

The following examples show how to use com.twitter.hbc.core.Constants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TwitterDataSource.java    From kafka-streams with Apache License 2.0 6 votes vote down vote up
private  Client getTwitterClient(Properties props, BlockingQueue<String> messageQueue) {

        String clientName = props.getProperty("clientName");
        String consumerKey = props.getProperty("consumerKey");
        String consumerSecret = props.getProperty("consumerSecret");
        String token = props.getProperty("token");
        String tokenSecret = props.getProperty("tokenSecret");
        List<String> searchTerms = Arrays.asList(props.getProperty("searchTerms").split(","));

        Authentication authentication = new OAuth1(consumerKey,consumerSecret,token,tokenSecret);
        Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
        StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint();

        hosebirdEndpoint.trackTerms(searchTerms);

        ClientBuilder clientBuilder = new ClientBuilder();
        clientBuilder.name(clientName)
                .hosts(hosebirdHosts)
                .authentication(authentication)
                .endpoint(hosebirdEndpoint)
                .processor(new StringDelimitedProcessor(messageQueue));

          return clientBuilder.build();

    }
 
Example #2
Source File: ClientBuilderTest.java    From hbc with Apache License 2.0 5 votes vote down vote up
@Test
public void testValidHttpMethod() {
  new ClientBuilder()
          .hosts(new HttpHosts(Constants.STREAM_HOST))
          .endpoint(StatusesSampleEndpoint.PATH, "gEt")
          .processor(new NullProcessor())
          .authentication(new BasicAuth("username", "password"))
          .build();

}
 
Example #3
Source File: BaseEndpoint.java    From hbc with Apache License 2.0 5 votes vote down vote up
public BaseEndpoint(String path, String httpMethod) {
  this.path = Preconditions.checkNotNull(path);
  this.httpMethod = Preconditions.checkNotNull(httpMethod);

  Preconditions.checkArgument(HttpConstants.checkHttpMethod(httpMethod));

  this.queryParameters = new ConcurrentHashMap<String, String>();
  this.postParameters = new ConcurrentHashMap<String, String>();
  this.apiVersion = Constants.CURRENT_API_VERSION;
}
 
Example #4
Source File: UserstreamEndpoint.java    From hbc with Apache License 2.0 5 votes vote down vote up
/**
 * Corresponds to setting `with=followings` when true.
 * See https://dev.twitter.com/docs/streaming-apis/parameters#with
 */
public void withFollowings(boolean followings) {
  if (followings) {
    addQueryParameter(Constants.WITH_PARAM, Constants.WITH_FOLLOWINGS);
  } else {
    removeQueryParameter(Constants.WITH_PARAM);
  }
}
 
Example #5
Source File: UserstreamEndpoint.java    From hbc with Apache License 2.0 5 votes vote down vote up
/**
 * Corresponds to setting `with=user` when true.
 * See https://dev.twitter.com/docs/streaming-apis/parameters#with
 */
public void withUser(boolean user) {
  if (user) {
    addQueryParameter(Constants.WITH_PARAM, Constants.WITH_USER);
  } else {
    removeQueryParameter(Constants.WITH_PARAM);
  }
}
 
Example #6
Source File: UserstreamEndpoint.java    From hbc with Apache License 2.0 5 votes vote down vote up
public void allReplies(boolean all) {
  if (all) {
    addQueryParameter(Constants.REPLIES_PARAM, Constants.REPLIES_ALL);
  } else {
    removeQueryParameter(Constants.REPLIES_PARAM);
  }
}
 
Example #7
Source File: DefaultStreamingEndpoint.java    From hbc with Apache License 2.0 5 votes vote down vote up
@Override
protected void addDefaultParams() {
  if (this.delimited) {
    addQueryParameter(Constants.DELIMITED_PARAM, Constants.DELIMITED_VALUE);
  } else {
    removeQueryParameter(Constants.DELIMITED_PARAM);
  }

  if (this.stallWarnings) {
    addQueryParameter(Constants.STALL_WARNING_PARAM, Constants.STALL_WARNING_VALUE);
  } else {
    removeQueryParameter(Constants.STALL_WARNING_PARAM);
  }
}
 
Example #8
Source File: DefaultStreamingEndpoint.java    From hbc with Apache License 2.0 5 votes vote down vote up
@Override
public final void setBackfillCount(int backfillCount) {
  if (isBackfillable()) {
    if (backfillCount != 0) {
      addQueryParameter(Constants.COUNT_PARAM, Integer.toString(backfillCount));
    } else {
      removeQueryParameter(Constants.COUNT_PARAM);
    }
  }
}
 
Example #9
Source File: ReconnectionManagerTest.java    From hbc with Apache License 2.0 5 votes vote down vote up
@Test
public void testEstimateBackfill() {
  ReconnectionManager rm = new BasicReconnectionManager(1);

  // some negative value should use the lower bound
  assertEquals(Constants.MIN_BACKOFF_MILLIS, rm.estimateBackfill(-1d));

  // some large value should use the upper bound
  assertEquals(Constants.MAX_BACKOFF_COUNT, rm.estimateBackfill(1000000d));

  // a value in the middle
  assertEquals(Constants.MIN_BACKOFF_MILLIS * 30, rm.estimateBackfill(30d));
}
 
Example #10
Source File: ClientBuilderTest.java    From hbc with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuilderSuccess() {
  new ClientBuilder()
          .hosts(new HttpHosts(Constants.STREAM_HOST))
          .endpoint(new StatusesSampleEndpoint())
          .processor(new NullProcessor())
          .authentication(new BasicAuth("username", "password"))
          .build();

}
 
Example #11
Source File: ClientBuilderTest.java    From hbc with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvalidHttpMethod() {
  try {
    new ClientBuilder()
            .hosts(new HttpHosts(Constants.STREAM_HOST))
            .endpoint(StatusesSampleEndpoint.PATH, "FAIL!")
            .processor(new NullProcessor())
            .authentication(new BasicAuth("username", "password"))
            .build();
    fail();
  } catch (Exception e) {
    // expected
  }
}
 
Example #12
Source File: SitestreamEndpoint.java    From hbc with Apache License 2.0 5 votes vote down vote up
public SitestreamEndpoint(List<Long> userIds) {
  super(PATH);

  Preconditions.checkNotNull(userIds, "List of users to follow must be provided");
  Preconditions.checkArgument(userIds.size() > 0, "List of users to follow must not be empty");
  Preconditions.checkArgument(userIds.size() <= 100, "Number of users to follow must be less than or equal to 100");

  addQueryParameter(Constants.FOLLOW_PARAM, Joiner.on(',').join(userIds));
}
 
Example #13
Source File: SitestreamControllerTest.java    From hbc with Apache License 2.0 5 votes vote down vote up
@Test
public void testProperlyCloseEntityContent() throws IOException, ControlStreamException {
  SitestreamController controlstreams = new SitestreamController(client, hosts, auth);
  InputStream stream = spy(new ByteArrayInputStream("message".getBytes(Constants.DEFAULT_CHARSET)));

  when(mockResponse.getEntity()).thenReturn(mockEntity);
  when(mockEntity.getContent()).thenReturn(stream);

  controlstreams.consumeHttpEntityContent(mockResponse);
  verify(stream).close();
}
 
Example #14
Source File: EndpointTest.java    From hbc with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultParams() throws MalformedURLException {
  StreamingEndpoint endpoint = new DefaultStreamingEndpoint("/path", HttpConstants.HTTP_GET, false);
  URL url = new URL(Constants.STREAM_HOST + endpoint.getURI());
  assertTrue(url.getQuery().contains(Constants.DELIMITED_PARAM + "=" + Constants.DELIMITED_VALUE));
  assertTrue(url.getQuery().contains(Constants.STALL_WARNING_PARAM + "=" + Constants.STALL_WARNING_VALUE));
}
 
Example #15
Source File: EndpointTest.java    From hbc with Apache License 2.0 5 votes vote down vote up
@Test
public void testSiteStreamEndpoint() {
  List<Long> followings = new ArrayList<Long>();
  followings.add(111111111L);
  followings.add(222222222L);

  SitestreamEndpoint endpoint = new SitestreamEndpoint(followings);

  assertEquals(Constants.FOLLOW_PARAM + "=111111111" + UrlCodec.encode(",") + "222222222", endpoint.getQueryParamString());
}
 
Example #16
Source File: EnterpriseStreamExample.java    From hbc with Apache License 2.0 5 votes vote down vote up
public static void run(String username,
                       String password,
                       String account,
                       String label,
                       String product) throws InterruptedException {
  BlockingQueue<String> queue = new LinkedBlockingQueue<String>(10000);

  BasicAuth auth = new BasicAuth(username, password);

  RealTimeEnterpriseStreamingEndpoint endpoint = new RealTimeEnterpriseStreamingEndpoint(account, product, label);

  // Create a new BasicClient. By default gzip is enabled.
  Client client = new ClientBuilder()
          .name("PowerTrackClient-01")
          .hosts(Constants.ENTERPRISE_STREAM_HOST)
          .endpoint(endpoint)
          .authentication(auth)
          .processor(new LineStringProcessor(queue))
          .build();

  // Establish a connection
  client.connect();

  // Do whatever needs to be done with messages
  for (int msgRead = 0; msgRead < 1000; msgRead++) {
    String msg = queue.take();
    System.out.println(msg);
  }

  client.stop();
}
 
Example #17
Source File: Twitter4jSampleStreamExample.java    From hbc with Apache License 2.0 5 votes vote down vote up
public void oauth(String consumerKey, String consumerSecret, String token, String secret) throws InterruptedException {
  // Create an appropriately sized blocking queue
  BlockingQueue<String> queue = new LinkedBlockingQueue<String>(10000);

  // Define our endpoint: By default, delimited=length is set (we need this for our processor)
  // and stall warnings are on.
  StatusesSampleEndpoint endpoint = new StatusesSampleEndpoint();

  Authentication auth = new OAuth1(consumerKey, consumerSecret, token, secret);
  // Authentication auth = new BasicAuth(username, password);

  // Create a new BasicClient. By default gzip is enabled.
  BasicClient client = new ClientBuilder()
    .hosts(Constants.STREAM_HOST)
    .endpoint(endpoint)
    .authentication(auth)
    .processor(new StringDelimitedProcessor(queue))
    .build();

  // Create an executor service which will spawn threads to do the actual work of parsing the incoming messages and
  // calling the listeners on each message
  int numProcessingThreads = 4;
  ExecutorService service = Executors.newFixedThreadPool(numProcessingThreads);

  // Wrap our BasicClient with the twitter4j client
  Twitter4jStatusClient t4jClient = new Twitter4jStatusClient(
    client, queue, Lists.newArrayList(listener1, listener2), service);

  // Establish a connection
  t4jClient.connect();
  for (int threads = 0; threads < numProcessingThreads; threads++) {
    // This must be called once per processing thread
    t4jClient.process();
  }

  Thread.sleep(5000);

  client.stop();
}
 
Example #18
Source File: FilterStreamExample.java    From hbc with Apache License 2.0 5 votes vote down vote up
public static void run(String consumerKey, String consumerSecret, String token, String secret) throws InterruptedException {
  BlockingQueue<String> queue = new LinkedBlockingQueue<String>(10000);
  StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();
  // add some track terms
  endpoint.trackTerms(Lists.newArrayList("twitterapi", "#yolo"));

  Authentication auth = new OAuth1(consumerKey, consumerSecret, token, secret);
  // Authentication auth = new BasicAuth(username, password);

  // Create a new BasicClient. By default gzip is enabled.
  Client client = new ClientBuilder()
          .hosts(Constants.STREAM_HOST)
          .endpoint(endpoint)
          .authentication(auth)
          .processor(new StringDelimitedProcessor(queue))
          .build();

  // Establish a connection
  client.connect();

  // Do whatever needs to be done with messages
  for (int msgRead = 0; msgRead < 1000; msgRead++) {
    String msg = queue.take();
    System.out.println(msg);
  }

  client.stop();

}
 
Example #19
Source File: TwitterHandler.java    From spring4ws-demos with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void init() {
	BlockingQueue<String> queue = new LinkedBlockingQueue<>(100);
	StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();

	endpoint.trackTerms(ImmutableList.of("ExtJS", "#extjs", "Sencha", "#java",
			"java8", "java9", "#websocket", "#SpringFramework", "html5", "javascript",
			"#kotlin", "kotlin"));
	endpoint.languages(ImmutableList.of("en", "de"));

	String consumerKey = this.environment.getProperty("twitter4j.oauth.consumerKey");
	String consumerSecret = this.environment
			.getProperty("twitter4j.oauth.consumerSecret");
	String accessToken = this.environment.getProperty("twitter4j.oauth.accessToken");
	String accessTokenSecret = this.environment
			.getProperty("twitter4j.oauth.accessTokenSecret");

	Authentication auth = new OAuth1(consumerKey, consumerSecret, accessToken,
			accessTokenSecret);

	this.client = new ClientBuilder().hosts(Constants.STREAM_HOST).endpoint(endpoint)
			.authentication(auth).processor(new StringDelimitedProcessor(queue))
			.build();

	this.executorService = Executors.newSingleThreadExecutor();

	TwitterStatusListener statusListener = new TwitterStatusListener(
			this.messagingTemplate, this.lastTweets);
	this.t4jClient = new Twitter4jStatusClient(this.client, queue,
			ImmutableList.of(statusListener), this.executorService);

	this.t4jClient.connect();
	this.t4jClient.process();
}
 
Example #20
Source File: SitestreamController.java    From hbc with Apache License 2.0 5 votes vote down vote up
public String getFriends(String streamId, long userId, int cursor) throws IOException, ControlStreamException {
  Endpoint endpoint = SitestreamEndpoint.friendsEndpoint(streamId);
  endpoint.addPostParameter(Constants.USER_ID_PARAM, Long.toString(userId));
  endpoint.addPostParameter(Constants.CURSOR_PARAM, Integer.toString(cursor));

  HttpUriRequest request = HttpConstants.constructRequest(hosts.nextHost(), endpoint, auth);
  HttpResponse response = makeControlStreamRequest(request);
  return consumeHttpEntityContent(response);
}
 
Example #21
Source File: SitestreamController.java    From hbc with Apache License 2.0 5 votes vote down vote up
public void removeUsers(String streamId, Collection<Long> userIds) throws IOException, ControlStreamException {
  Preconditions.checkArgument(userIds.size() >= 1 && userIds.size() <= 100, "The userId parameter can be supplied with up to 100 user IDs.");
  Endpoint endpoint = SitestreamEndpoint.removeUserEndpoint(streamId);
  endpoint.addPostParameter(Constants.USER_ID_PARAM, Joiner.on(',').join(userIds));

  HttpUriRequest request = HttpConstants.constructRequest(hosts.nextHost(), endpoint, auth);
  consumeHttpEntityContent(makeControlStreamRequest(request));
}
 
Example #22
Source File: TwitterStream.java    From AIBlueprints with MIT License 5 votes vote down vote up
public TwitterStream(SentimentDetector sentimentDetector,
                     Gson gson,
                     Properties props) {
    this.sentimentDetector = sentimentDetector;
    this.gson = gson;

    msgQueue = new LinkedBlockingQueue<String>(100000);

    Hosts hosts = new HttpHosts(Constants.STREAM_HOST);
    StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();

    List<String> terms = Lists.newArrayList(
            props.getProperty("twitter_terms")
                    .split("\\s*,\\s*"));
    endpoint.trackTerms(terms);

    Authentication auth = new OAuth1(
            props.getProperty("twitter_consumer_key"),
            props.getProperty("twitter_consumer_secret"),
            props.getProperty("twitter_token"),
            props.getProperty("twitter_token_secret"));
    ClientBuilder builder = new ClientBuilder()
            .name("SmartCode-Client-01")
            .hosts(hosts)
            .authentication(auth)
            .endpoint(endpoint)
            .processor(new StringDelimitedProcessor(msgQueue));
    client = builder.build();
    client.connect();
}
 
Example #23
Source File: SitestreamController.java    From hbc with Apache License 2.0 5 votes vote down vote up
public void addUsers(String streamId, Collection<Long> userIds) throws IOException, ControlStreamException {
  Preconditions.checkArgument(userIds.size() >= 1 && userIds.size() <= 100, "The userId parameter can be supplied with up to 100 user IDs.");
  Endpoint endpoint = SitestreamEndpoint.addUserEndpoint(streamId);
  endpoint.addPostParameter(Constants.USER_ID_PARAM, Joiner.on(',').join(userIds));

  HttpUriRequest request = HttpConstants.constructRequest(hosts.nextHost(), endpoint, auth);
  consumeHttpEntityContent(makeControlStreamRequest(request));
}
 
Example #24
Source File: SitestreamController.java    From hbc with Apache License 2.0 5 votes vote down vote up
public void removeUser(String streamId, long userId) throws IOException, ControlStreamException {
  Endpoint endpoint = SitestreamEndpoint.removeUserEndpoint(streamId);
  endpoint.addPostParameter(Constants.USER_ID_PARAM, Long.toString(userId));

  HttpUriRequest request = HttpConstants.constructRequest(hosts.nextHost(), endpoint, auth);
  consumeHttpEntityContent(makeControlStreamRequest(request));
}
 
Example #25
Source File: SitestreamController.java    From hbc with Apache License 2.0 5 votes vote down vote up
/**
 * TODO: This must be limited to 25 adds per seconds
 */
public void addUser(String streamId, long userId) throws IOException, ControlStreamException {
  Endpoint endpoint = SitestreamEndpoint.addUserEndpoint(streamId);
  endpoint.addPostParameter(Constants.USER_ID_PARAM, Long.toString(userId));

  HttpUriRequest request = HttpConstants.constructRequest(hosts.nextHost(), endpoint, auth);
  consumeHttpEntityContent(makeControlStreamRequest(request));
}
 
Example #26
Source File: TwitterStream.java    From AIBlueprints with MIT License 5 votes vote down vote up
public TwitterStream(Gson gson, Properties props, BlockingQueue<Map<String,Object>> imageQueue) {
    this.gson = gson;
    this.imageQueue = imageQueue;

    msgQueue = new LinkedBlockingQueue<String>(100000);

    Hosts hosts = new HttpHosts(Constants.STREAM_HOST);
    StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();

    List<String> terms = Lists.newArrayList(
            props.getProperty("twitter_terms")
                    .split("\\s*,\\s*"));
    endpoint.trackTerms(terms);

    Authentication auth = new OAuth1(
            props.getProperty("twitter_consumer_key"),
            props.getProperty("twitter_consumer_secret"),
            props.getProperty("twitter_token"),
            props.getProperty("twitter_token_secret"));
    ClientBuilder builder = new ClientBuilder()
            .name("SmartCode-Client-01")
            .hosts(hosts)
            .authentication(auth)
            .endpoint(endpoint)
            .processor(new StringDelimitedProcessor(msgQueue));
    client = builder.build();
    client.connect();
}
 
Example #27
Source File: GetTwitter.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
    final Event event = eventQueue.poll();
    if (event != null) {
        switch (event.getEventType()) {
            case STOPPED_BY_ERROR:
                getLogger().error("Received error {}: {} due to {}. Will not attempt to reconnect", new Object[]{event.getEventType(), event.getMessage(), event.getUnderlyingException()});
                break;
            case CONNECTION_ERROR:
            case HTTP_ERROR:
                getLogger().error("Received error {}: {}. Will attempt to reconnect", new Object[]{event.getEventType(), event.getMessage()});
                client.reconnect();
                break;
            default:
                break;
        }
    }

    final String tweet = messageQueue.poll();
    if (tweet == null) {
        context.yield();
        return;
    }

    FlowFile flowFile = session.create();
    flowFile = session.write(flowFile, new OutputStreamCallback() {
        @Override
        public void process(final OutputStream out) throws IOException {
            out.write(tweet.getBytes(StandardCharsets.UTF_8));
        }
    });

    final Map<String, String> attributes = new HashMap<>();
    attributes.put(CoreAttributes.MIME_TYPE.key(), "application/json");
    attributes.put(CoreAttributes.FILENAME.key(), flowFile.getAttribute(CoreAttributes.FILENAME.key()) + ".json");
    flowFile = session.putAllAttributes(flowFile, attributes);

    session.transfer(flowFile, REL_SUCCESS);
    session.getProvenanceReporter().receive(flowFile, Constants.STREAM_HOST + client.getEndpoint().getURI().toString());
}
 
Example #28
Source File: SampleStreamExample.java    From Java-for-Data-Science with MIT License 5 votes vote down vote up
public static void streamTwitter(String consumerKey, String consumerSecret, String accessToken, String accessSecret) throws InterruptedException {

		BlockingQueue<String> statusQueue = new LinkedBlockingQueue<String>(10000);

		StatusesSampleEndpoint ending = new StatusesSampleEndpoint();
		ending.stallWarnings(false);

		Authentication twitterAuth = new OAuth1(consumerKey, consumerSecret, accessToken, accessSecret);

		BasicClient twitterClient = new ClientBuilder()
				.name("Twitter client")
				.hosts(Constants.STREAM_HOST)
				.endpoint(ending)
				.authentication(twitterAuth)
				.processor(new StringDelimitedProcessor(statusQueue))
				.build();


		twitterClient.connect();


		for (int msgRead = 0; msgRead < 1000; msgRead++) {
			if (twitterClient.isDone()) {
				System.out.println(twitterClient.getExitEvent().getMessage());
				break;
			}

			String msg = statusQueue.poll(10, TimeUnit.SECONDS);
			if (msg == null) {
				System.out.println("Waited 10 seconds - no message received");
			} else {
				System.out.println(msg);
			}
		}

		twitterClient.stop();

		System.out.printf("%d messages processed!\n", twitterClient.getStatsTracker().getNumMessages());
	}
 
Example #29
Source File: StringDelimitedProcessor.java    From hbc with Apache License 2.0 4 votes vote down vote up
@Override
public void setup(InputStream input) {
  reader = new DelimitedStreamReader(input, Constants.DEFAULT_CHARSET, DEFAULT_BUFFER_SIZE);
}
 
Example #30
Source File: SitestreamExample.java    From hbc with Apache License 2.0 4 votes vote down vote up
public void run(String consumerKey, String consumerSecret, String token, String tokenSecret)
        throws InterruptedException, ControlStreamException, IOException {
  // Create an appropriately sized blocking queue
  BlockingQueue<String> queue = new LinkedBlockingQueue<String>(10000);

  // Define our endpoint: By default, delimited=length is set (we need this for our processor)
  // and stall warnings are on.
  List<Long> followings = new ArrayList<Long>();
  followings.add(111111111L);
  followings.add(222222222L);

  SitestreamEndpoint endpoint = new SitestreamEndpoint(followings);
  Authentication auth = new OAuth1(consumerKey, consumerSecret, token, tokenSecret);

  // Create a new BasicClient. By default gzip is enabled.
  BasicClient client = new ClientBuilder()
          .hosts(Constants.SITESTREAM_HOST)
          .endpoint(endpoint)
          .authentication(auth)
          .processor(new StringDelimitedProcessor(queue))
          .build();

  // Create an executor service which will spawn threads to do the actual work of parsing the incoming messages and
  // calling the listeners on each message
  int numProcessingThreads = 4;
  ExecutorService service = Executors.newFixedThreadPool(numProcessingThreads);

  // Wrap our BasicClient with the twitter4j client
  Twitter4jSitestreamClient t4jClient = new Twitter4jSitestreamClient(
          client, queue, Lists.newArrayList(listener), service);

  // Establish a connection
  t4jClient.connect();
  for (int threads = 0; threads < numProcessingThreads; threads++) {
    // This must be called once per processing thread
    t4jClient.process();
  }

  Thread.sleep(5000);

  // Create a sitestream controller to issue controlstream requests
  SitestreamController controller = new SitestreamController(auth);

  controller.getFriends(t4jClient.getStreamId(), 12345L);
  controller.addUser(t4jClient.getStreamId(), 987765L);

  client.stop();
}