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

Sending messages with the mechanize approach fails #7

Closed
Vogel612 opened this issue Nov 7, 2014 · 11 comments
Closed

Sending messages with the mechanize approach fails #7

Vogel612 opened this issue Nov 7, 2014 · 11 comments

Comments

@Vogel612
Copy link
Collaborator

Vogel612 commented Nov 7, 2014

Mechanize doesn't let us send messages yet. It seems that the Login to chat isn't succesfully mimicked yet, as the response is: "you must login to send messages"

A login to the SE-OpenId has been confirmed by checking the result page after login for the class "profile-me", that's given to the topbar overview of logged in account

@Vogel612 Vogel612 self-assigned this Nov 7, 2014
@Vogel612
Copy link
Collaborator Author

Vogel612 commented Nov 7, 2014

I am also tracking this ticket in my Trello Board

@Unihedro
Copy link
Owner

Unihedro commented Nov 8, 2014

Never liked Mechanize anyway. :)

@Vogel612
Copy link
Collaborator Author

Vogel612 commented Nov 8, 2014

Well HTMLUnit didn't really look simple though. But hey the ultimate decision is yours @Vincentyification

@fge
Copy link
Collaborator

fge commented Nov 8, 2014

Hold on a minute; are we talking tests here? If yes, what is it you want tested?

I have the suspicion that something is fundamentally off...

@Vogel612
Copy link
Collaborator Author

Vogel612 commented Nov 8, 2014

No we're not talking tests... we're talking non-working core functionality.

Sending messages to chat is currently not possible... interestingly on chat.so we're hitting a server-side error

Oops! Something bad happened.

On chat.se we're getting a different message:

You must login to post.

The behavior is reproducible

@Unihedro
Copy link
Owner

Unihedro commented Nov 8, 2014

@fge Testing in BlueCheese Monster's Home has proven Mechanize engine in 6986ff2 not to work properly when attempting to send a message with relevant crash log:

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:187)
    at com.google.gson.Gson.fromJson(Gson.java:805)
    at com.google.gson.Gson.fromJson(Gson.java:770)
    at com.google.gson.Gson.fromJson(Gson.java:719)
    at com.google.gson.Gson.fromJson(Gson.java:691)
    at com.gmail.inverseconduit.chat.JSONChatConnection.queryEventsFor(JSONChatConnection.java:52)
    at com.gmail.inverseconduit.chat.MessageRelay.lambda$null$0(MessageRelay.java:116)
    at com.gmail.inverseconduit.chat.MessageRelay$$Lambda$4/1127556867.accept(Unknown Source)
    at java.util.HashMap$KeySet.forEach(HashMap.java:928)
    at com.gmail.inverseconduit.chat.MessageRelay.lambda$monitorRooms$1(MessageRelay.java:115)
    at com.gmail.inverseconduit.chat.MessageRelay$$Lambda$3/1921857454.accept(Unknown Source)
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    at com.gmail.inverseconduit.chat.MessageRelay.monitorRooms(MessageRelay.java:114)
    at com.gmail.inverseconduit.chat.MessageRelay$$Lambda$1/1876631416.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    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)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
    at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:387)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
    ... 21 more

@Vogel612
Copy link
Collaborator Author

Vogel612 commented Nov 8, 2014

@Vincentyification this stacktrace is coming from the event reading code... in the stacktrace you can see the call to MessageRelay#monitorRooms()

@fge
Copy link
Collaborator

fge commented Nov 8, 2014

Why not using a library such as Apache's httpclient, for instance? Also, about the "not logged in" message, isn't that the case of a missing cookie or something?

@Vogel612
Copy link
Collaborator Author

Vogel612 commented Nov 8, 2014

For one: mechanize and html unit are libraries. Secondly: yes that is a 'missing cookie'. The login to chat is still missing a few steps. I have confirmed a working login to the main site, though.

But the login to chat isn't working yet, especially since it requires multiple steps (5 IIRC).
I was successful in doing the first. I will hunt the rest down over this weekend.

@Vogel612
Copy link
Collaborator Author

Vogel612 commented Nov 8, 2014

As of now, the Login might get problematic, since the chat-login link blows up in our face. For more information, see GistLabs/mechanize#73

@Vogel612
Copy link
Collaborator Author

Mechanize was shot down and is no more used in the project. This is effective as of d528e87

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

No branches or pull requests

3 participants