01 Apr 2014, 12:28
Generic-user-small

Suresh Kumar R (1 post)

It seems that maps in R17 rc2 does not support => operator in receive pattern matching. It supports only := operator in pattern patching in receive block. This error had to be corrected in about fice files in the web sockets folder.

Generally the websockets folder seems to have many errors. I wonder if it was ever tested before the code was uploaded as there are syntax errors which could never be present if it was ever tested.

Thanks to Joe, the books is excellent but the accompanying source code makes me doubt whether it was ever tested at all. I am also surprised to see that no one has reported any errors which means no one tried running it or they fixed issues easily and kept silent. By the way, I have not tested except 2 or 3 examples so I am not sure if the errors are only unique to websockets or all the other examples also. One would expect accompanying code to have been tested so that its easy to learn as it is functional programming is itself hard enough to learn with new ErLang syntax.

It had taken me 2 days to come to this stage so I am going to take a break now and get to it. It would be great if any one of you can tell me if there is more proper error free source code maintained anywhere so that I can download and use it along with the book. Thanks.

Below 5 files are using wrong operator for maps in pattern matching. The operator should have been := and its =>. I guess the operators may have changed in 17RC2 after the book was published.

chat1.erl - Line 17 and 24 shows illegal pattern chat2.erl 17, 31 and 34 shows illegal pattern clock1.erl interact1.erl shell1.erl

Below 2 files have error in syntax.

interact1.erl is also missing the operator -> in line 16 shell1.erl also has closing curly brackets at wrong location in map in line 1

After you fix the above, you get below error. 1> {“init terminating in do_boot”,{{badmatch,{error,{not_started,cowlib}}},[{websockets,start_link,1,[{file,”websockets.erl”},{line,39}]},{init,start_it,1,[]},{init,start_em,1,[]}]}}

The file websockets.erl should have start cowlib and crypt applications. Once you fix them, then the app and browse to localhost:2233, you get below error.

=ERROR REPORT==== 1-Apr-2014::17:47:05 === Ranch listener my_named_thing had connection process started with cowboy_protocol:start_link/4 at <0.152.0> exit with reason: {{badmatch,false},[{cowboy_router,execute,2,[{file,”src/cowboy_router.erl”},{line,167}]},{cowboy_protocol,execute,4,[{file,”src/cowboy_protocol.erl”},{line,435}]}]}

=ERROR REPORT==== 1-Apr-2014::17:47:05 === Ranch listener my_named_thing had connection process started with cowboy_protocol:start_link/4 at <0.152.0> exit with reason: {{badmatch,false},[{cowboy_router,execute,2,[{file,”src/cowboy_router.erl”},{line,167}]},{cowboy_protocol,execute,4,[{file,”src/cowboy_protocol.erl”},{line,435}]}]}

02 Jul 2014, 16:39
Generic-user-small

Fabio T (1 post)

Here you will find the example working

https://github.com/joearms/ezwebframe

  You must be logged in to comment